Reputation: 61
I have two lists, same size, one is y_data and one is x_data x_data is a time hh:mm:ss during day, in fact each minute each serie is 1440 long.
problem is :
fig = Figure(figsize=(4,3))
a = gif.add_subplot(111)
a.plot(x_data, y_data)
give an unreadable x_axis (too many labels), if i reduce x_data to [range(24)]
for instance, plot gives an error.
Question :
I'd like to have only 24 items on x_axis scale (each hour, so 1 item each 60 x_data points)
is there a simple way to achieve this ? set_autoscale_on(False)
and then manually setting limits seems a very complex way to achieve this (and I would loose the benefits from autoscaling on y axis).
Another solution seems to involve a.xaxis.set_ticks()
but i have to crate a new serie.
o I'd like to use x_data but just limit the number of ticks shown on x_axis, is there a way to do it ?
Upvotes: 5
Views: 13679
Reputation: 24268
The pyplot interface of matplotlib provides a function locator_params, where you can set this option:
fig = Figure(figsize=(4,3))
a = fig.add_subplot(111)
a.plot(x_data, y_data)
a.locator_params(nbins=4)
Upvotes: 7