Chris Withers wrote:
>> So, basically make the x axis time instead of numbers.
>> I think the problem is actually that the daets are quite long in their
>> format. If they were rotated through 90 degress it'd likely be fine.
>> How would I do this?
>
> I'm not sure it is the easiest way, but it works for me:
>
> for label in ax.xaxis.get_majorticklabels():
> label.set_rotation(+90)
To adjust tick labels when using dates, you could also try
Figure.autofmt_xdate (I added it to the example code you were using
below). Internally it sets the rotation of the xticklabels as described
above, but also sets horizontal alignment of the labels and is
especially useful if you have multiple subplots.
-Ryan
from datetime import datetime
from time import sleep
ion() # interactive mode 'on'
fig = figure()
ax = fig.add_subplot(111, autoscale_on=True)
x, y = [datetime.now()], [0]
line = plot(x, y, label="my_data")[0]
# get the line-object as the first element
# of the tuple returned by plot legend()
for i in arange(30):
x.append(datetime.now()) # append new values
y.append(i**2)
line.set_data(x,y) # reset data
ax.relim() # reset axes limits
ax.autoscale_view() # rescale axes
fig.autofmt_xdate() # adjust the xtick labels
draw() # redraw current figure
sleep(0.3) # wait 0.3 seconds
ioff()
show()
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users