On Sunday 08 May 2005 8:34 am, Florian Lindner wrote:
> Hello,
> can I use strings as units for the x-axis. Like
> plot([1,2,3],['A','B','C']). Of course, for every line the second argument
> must be the same.
> Is that possible?
The way to get strings along the xaxis is to use the xticks function if you
are using the pylab interface.
plot([1,2,3])
xticks([0,1,2],['A','B','C'])
or you can use the axes xaxis.set_ticks and xaxis.set_ticklabels:
ax=axes()
plot([0,1,2])
ax.xaxis.set_ticks([0,1,2])
ax.xaxis.set_ticklabels(['A','B','C'])
draw()
Are you familiar with the examples?
http://matplotlib.sourceforge.net/matplotlib_examples_0.80.zip
You might not think to look there in barchart_demo.py, but it explains this
procedure.
Hope this helps,
Darren
|