Hi Ben,
Thanks for the pointer to "spines". Much cleaner way to hide/play around with
axes. I switched to using spines to hide right and top axes. However, the
misalignment of ticks and axes remains (TkAgg backend). So I'll just have to
switch to a different backend I suppose...
-Aditya.
>________________________________
> From: Benjamin Root <ben.r...@ou.edu>
>To: Aditya Gilra <aditya_gi...@yahoo.com>
>Cc: "matplotlib-users@lists.sourceforge.net"
><matplotlib-users@lists.sourceforge.net>
>Sent: Friday, 1 March 2013 12:10 AM
>Subject: Re: [Matplotlib-users] Line2D and ticks are misaligned in TkAgg
>backend
>
>
>
>
>
>On Thu, Feb 28, 2013 at 7:00 AM, Aditya Gilra <aditya_gi...@yahoo.com> wrote:
>
>Hi,
>>
>>
>>I need to set the frame off for my plots, so that I can have axes only on the
>>sides I want, rather than on all four sides.
>>I do it this way:
>>
>>
>>from pylab import *
>>
>>fig = figure(figsize=(3,2),dpi=300,facecolor='w')
>>ax =
fig.add_subplot(111,frameon=False)
>>ax.add_artist(Line2D((0, 0), (0, 1),color='k',linewidth=0.5))
>>ax.add_artist(Line2D((1, 1), (0, 1),color='k',linewidth=0.5))
>>ax.set_yticks([0,1])
>>ax.set_xticks([0,1])
>>show()
>>
>>
>
>Much easier way is to use "spines":
>http://matplotlib.org/examples/pylab_examples/spine_placement_demo.html
>
>
>Unfortunately, now the ticks and axes-lines are misaligned, as seen in the
>screenshots attached. In the second screenshot, I've panned the plot, so the
>misalignment is even more visible.
>>
>>
>>matplotlib.__version__ gives '1.1.1rc'
>>matplotlib.get_backend() gives 'TkAgg'
>>
>>
>>-------
>>
>>
>>If I use 'WX' backend by adding these two line before the above code (before
>>pylab import):
>>
>>
>>import matplotlib
>>matplotlib.use('WX')
>>
>>
>>then the misalignment still appears to be there, but that is because the
>>Line2Ds are clipped in their width, but the ticks are not. This is seen by
>>panning the plot.
>>
>>
>>I can set the clipping of the Line2Ds off by doing:
>>l1 = ax.add_artist(Line2D((0, 0), (0, 1),color='k',linewidth=0.5))
>>l1.set_clip_on(False)
>>l2 = ax.add_artist(Line2D((1, 1), (0, 1),color='k',linewidth=0.5))
>>l2.set_clip_on(False)
>>
>>
>>So, WX backend is fine.
>>
>>
>>Backend 'GTK' doesn't even have the above clipping problem.
>>
>>
>
>Now that is interesting and should be investigated further.
>
>Ben Root
>
>
>
>
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
endpoint security space. For insight on selecting the right partner to
tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users