|
From: Benjamin R. <ben...@ou...> - 2013-03-01 00:16:29
|
On Thu, Feb 28, 2013 at 7:00 AM, Aditya Gilra <adi...@ya...>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 |