|
From: Michael H. <mh...@al...> - 2011-11-19 13:36:50
|
On 10/09/2011 12:03 PM, Lorenzo Mentaschi wrote:
> in order to make gnuplot-py deal with xtics labels of string type
> (without building the gnuplot command in user code), I added this method
> to Gnuplot class:
>
>
> ######
> def set_tics_labels(self, labels, axis = 'x'):
> cmd = 'set %stics (' % (axis,)
> for indx, label in zip(range(len(labels)), labels):
> cmd += '"%s" %i,' % (label, indx,)
> cmd = cmd.strip(',') + ")"
> self(cmd)
> ######
>
>
> This seems to work for me. Is there any smarter way to do this?
Thanks for your submission.
If I understand correctly, your function takes a list of label strings
as argument and places the 0th label in the list at axis position 0.0,
the 1st label at axis position 1.0, etc. Is that correct?
Because this seems quite special-purpose. The gnuplot "set *tics"
commands are much more flexible. They allow labels to be placed at
arbitrary positions and allow the user to specify which tic marks are
major vs. minor. If we are going to build a set_tics_labels() command
into Gnuplot, then I think it should provide access to more of gnuplot's
functionality.
What do you think of the attached patch?
Michael
--
Michael Haggerty
mh...@al...
http://softwareswirl.blogspot.com/
|