setp/xticklabel problem
Matplotlib-users,
I am stuck on a problem in trying to label the xaxis for some plots. I am trying to do something similar to the following:
plot([1,2,3,4], [1,4,9,16])
labels = setp(gca(), ‘xticklabels’, [‘one’, ‘two’, ‘three’, ‘four’])
set(labels, ‘rotation’, ‘vertical’)
show()
Once the plot is displayed, moving the mouse causes the following stack trace:
TypeError: list indices must be integers Traceback (most recent call last):
File “/usr/lib/python2.4/site-packages/matplotlib/backends/backend_gtk.py”, line 188, in motion_notify_event
FigureCanvasBase.motion_notify_event(self, x, y)
File “/usr/lib/python2.4/site-packages/matplotlib/backend_bases.py”, line 797, in motion_notify_event
func(event)
File “/usr/lib/python2.4/site-packages/matplotlib/backend_bases.py”, line 1085, in mouse_move
try: s = event.inaxes.format_coord(event.xdata, event.ydata)
File “/usr/lib/python2.4/site-packages/matplotlib/axes.py”, line 611, in format_coord
xs = self.format_xdata(x)
File “/usr/lib/python2.4/site-packages/matplotlib/axes.py”, line 593, in format_xdata
val = func(x)
File “/usr/lib/python2.4/site-packages/matplotlib/ticker.py”, line 152, in format_data
return self.__call__(value)
File “/usr/lib/python2.4/site-packages/matplotlib/ticker.py”, line 178, in call
else: return self.seq[pos]
Line 3 of the code seems to be the culprit. Does anyone have any idea on how I might be able to workaround this? I have seen posts describing issues that seem to be related to the same problem, but I have not seen a solution.
Thanks,
Brian Bowen