Hello,
I am working on a plot in which I need to modify the value of the xticks. A
snippet of my code is attached below:
fig=figure()
>
> gs=matplotlib.gridspec.GridSpec(1,2,width_ratios=[3,1])
> gs.update(wspace=0.1)
> ax=subplot(gs[0])
> ylabel('Frequency (cm'+r'$^{-1}$'+')')
> for i in range(0,len(ydata)):
> plot(xdata[i],ydata[i],'r-',linewidth=1.5)
> plot(xdata[0],[0.0]*len(xdata[0]),'k:')
>
> pos=[0,49.9856985699,99.9713971397,170.661849982,212.979781775,283.67023461\
> 7,333.655933187,375.97386498]
>
> locs,labels=xticks(pos,[r'$\Gamma$','X','M',r'$\Gamma$','Z','A','R','X'])
> for i in range(0,len(pos)):
> plt.axvline(x=pos[i],linewidth=0.5,color='k',alpha=0.5)
> axis([0,375.98,0,300])
> ax2=subplot(gs[1])
> plot(dosydata,dosxdata,'r-',linewidth=1.5)
> a=gca()
> b=a.get_xticks()
> print b
> a.xaxis.set_ticks([0.0, 0.015, 0.03])
> a.tick_params(axis='x',labelsize=14)
> a.set_xlim([0,0.03])
> a.set_ylim([0,300])
> ax.label_outer()
> ax2.label_outer()
> show()
>
>
It's a plot with two subplots. Anyway, the issue I'm running into concerns
the x-axis on the second subplot. As you can see I have set it explicitly
with "a.xaxis.set_ticks([0.0, 0.015, 0.03])". However, when I do this it
shows up as (0.000, 0.015,0.030) which I would really like it to look like
(0,0.015,0.03). In other words, I don't want extra zeros because they are
unnecessary and make the text run into my other subplot. So I need to be
able to format them somehow. How would I achieve this selective formatting
(because of course I want 0.015 to show up that way and not 0.01).
Thanks so much in advance for the help!
Best,
Brad
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users