[Tioga-users] Gridlines
David MacMahon
davidm at astro.berkeley.edu
Sat May 3 03:06:33 EDT 2008
Thanks, Vincent! I was just typing another message saying that I
think I found a fairly straightforward way to do it by using really
long tick marks. It is not so generalized as yours as it requires
the ticks to be both inside and not outside, but it does work with
minor tick marks, too. Here's the text I was typing...
I tried "t.xaxis_major_tick_length = t.bounds_height", but that did
not work because xaxis_major_tick_length= expects a value in "units
of the default text height". So then I tried...
t.xaxis_major_tick_length = t.bounds_height /
t.default_text_height_dy / 2
t.yaxis_major_tick_length = t.bounds_width /
t.default_text_height_dx / 2
...and it worked!
Dave
On May 2, 2008, at 23:40 , Vincent Fourmond wrote:
> David MacMahon wrote:
>> Is there an easy way to put grid lines on a plot? By easy, I mean an
>> existing method I can call with perhaps a few options like line style
>> and color.
>
> For now, no.
>
>> If not, I guess I'll have to write one myself that gets the axis
>> information and the plot boundaries and then draws the grid lines
>> individually. Does anyone have any tips on how to do that? How
>> would I
>> get minor tick locations?
>
> Seems that my additions to the axes function are not only useful to
> myself ;-)... Here is the code I use in ctioga:
>
> # Draws the background lines associated with this axis, if
> # applicable.
> #
> # This function requires Tioga SVN -r 482
> def draw_lines(t, container)
>
> return unless @lines_color
> # First, getting major ticks location from tioga
> info = t.axis_information(axis_argument(t, container))
>
> if info['vertical']
> x0 = t.bounds_left
> x1 = t.bounds_right
> else
> y0 = t.bounds_bottom
> y1 = t.bounds_top
> end
>
> t.context do
> t.stroke_color = @lines_color
> t.line_width = @lines_width || info['major_tick_width']
> t.line_type = @lines_style
> for val in info['major']
> if info['vertical']
> t.stroke_line(x0, val, x1, val)
> else
> t.stroke_line(val, y0, val, y1)
> end
> end
> end
> end
>
> There is currently no way to get minor tick location (much more
> delicate to extract from the C level than the major ticks). I probably
> should give it a try, though.
>
> Cheers,
>
> Vincent
> _______________________________________________
> Tioga-users mailing list
> Tioga-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/tioga-users
More information about the Tioga-users
mailing list