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
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to