[Matplotlib-users] ticks at 0 and 2pi From: Nikolaus Rath - 2010-04-20 14:20:17 Hello, I'm trying to plot something from 0 to 2pi: fig = plt.figure() ax = fig.add_subplot(111) ax.set_title('Radial Magnetic Field') ax.set_ylabel(r'Poloidal Angle $\theta$') ax.set_xlabel(r'Toroidal Angle $\phi$') ax.set_xticks([0, 2 * math.pi]) ax.set_xticklabels(['0', r'$2\pi$']) ax.set_yticklabels([r'$-\pi$', r'$\pi$']) ax.set_yticks([-math.pi, math.pi]) ax.set_xlim(xmin=0, xmax=2 * math.pi) ax.set_ylim(ymin= -math.pi, ymax=math.pi) But unfortunately the ticks for x=2pi and y=pi are not shown. They do show up if I move them a tiny bit: ax.set_xticks([0, 2 * math.pi * 0.98]) ax.set_yticks([-math.pi, math.pi * 0.98]) But obviously this is ugly. Is there a way to show the labels without moving the to the wrong position and without extending the axis limits (since that introduces a white border)? Best, -Nikolaus -- »Time flies like an arrow, fruit flies like a Banana.« PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C 
 [Matplotlib-users] ticks at 0 and 2pi From: Nikolaus Rath - 2010-04-20 14:20:17 Hello, I'm trying to plot something from 0 to 2pi: fig = plt.figure() ax = fig.add_subplot(111) ax.set_title('Radial Magnetic Field') ax.set_ylabel(r'Poloidal Angle $\theta$') ax.set_xlabel(r'Toroidal Angle $\phi$') ax.set_xticks([0, 2 * math.pi]) ax.set_xticklabels(['0', r'$2\pi$']) ax.set_yticklabels([r'$-\pi$', r'$\pi$']) ax.set_yticks([-math.pi, math.pi]) ax.set_xlim(xmin=0, xmax=2 * math.pi) ax.set_ylim(ymin= -math.pi, ymax=math.pi) But unfortunately the ticks for x=2pi and y=pi are not shown. They do show up if I move them a tiny bit: ax.set_xticks([0, 2 * math.pi * 0.98]) ax.set_yticks([-math.pi, math.pi * 0.98]) But obviously this is ugly. Is there a way to show the labels without moving the to the wrong position and without extending the axis limits (since that introduces a white border)? Best, -Nikolaus -- »Time flies like an arrow, fruit flies like a Banana.« PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C 
 Re: [Matplotlib-users] ticks at 0 and 2pi From: Ryan May - 2010-04-20 14:36:08 On Tue, Apr 20, 2010 at 8:58 AM, Nikolaus Rath wrote: > Hello, > > I'm trying to plot something from 0 to 2pi: > >    fig = plt.figure() >    ax = fig.add_subplot(111) >    ax.set_title('Radial Magnetic Field') >    ax.set_ylabel(r'Poloidal Angle $\theta$') >    ax.set_xlabel(r'Toroidal Angle $\phi$') > >    ax.set_xticks([0, 2 * math.pi]) >    ax.set_xticklabels(['0', r'$2\pi$']) >    ax.set_yticklabels([r'$-\pi$', r'$\pi$']) >    ax.set_yticks([-math.pi, math.pi]) > >    ax.set_xlim(xmin=0, xmax=2 * math.pi) >    ax.set_ylim(ymin= -math.pi, ymax=math.pi) I don't see the problem here, I get the ticks as specified. What version of matplotlib are you using? What backend are you using? Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma 
 Re: [Matplotlib-users] ticks at 0 and 2pi From: Nikolaus Rath - 2010-04-20 15:07:40 On 04/20/2010 10:29 AM, Ryan May wrote: > On Tue, Apr 20, 2010 at 8:58 AM, Nikolaus Rath wrote: >> Hello, >> >> I'm trying to plot something from 0 to 2pi: >> >> fig = plt.figure() >> ax = fig.add_subplot(111) >> ax.set_title('Radial Magnetic Field') >> ax.set_ylabel(r'Poloidal Angle $\theta$') >> ax.set_xlabel(r'Toroidal Angle $\phi$') >> >> ax.set_xticks([0, 2 * math.pi]) >> ax.set_xticklabels(['0', r'$2\pi$']) >> ax.set_yticklabels([r'$-\pi$', r'$\pi$']) >> ax.set_yticks([-math.pi, math.pi]) >> >> ax.set_xlim(xmin=0, xmax=2 * math.pi) >> ax.set_ylim(ymin= -math.pi, ymax=math.pi) > > I don't see the problem here, I get the ticks as specified. What > version of matplotlib are you using? What backend are you using? Actually, now that I tried it again, it suddenly works. Strange... Sorry for the pointless mail. Best, -Nikolaus -- »Time flies like an arrow, fruit flies like a Banana.« PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C