pybokeh
2015-03-14 02:56:00 UTC
Hello,
I'm trying to learn if there is a better or less tedious way of changing the
x-axis time scale interval size when plotting time series data using
MATPLOTLIB.
To account for all the different x-axis intervals that I may end up using, I
usually do the following imports:
from matplotlib.dates import YearLocator, MonthLocator, WeekdayLocator,
DateFormatter, DayLocator
from matplotlib.dates import MO, TU, WE, TH, FR, SA, SU
Then I specify specific intervals by doing the following:
year = YearLocator()
month = MonthLocator(bymonth=range(1,13), bymonthday=1, interval=1)
week = WeekdayLocator(byweekday=MO) # Every MOnday
day = DayLocator(bymonthday=range(1,32), interval=1)
Then apply any of the above formats by doing:
axes.xaxis.set_major_locator(year)
axes.xaxis.set_major_locator(month)
I find all that above too tedious since I may then decide to change the
intervals to something different to experiment.
With R's ggplot2 or Yhat's ggplot, it is very simple and intuitive to change
the x-axis scale interval. You just need to specify the breaks and
minor_breaks interval like so:
scale_x_datetime(labels=date_format("%Y-%m"), breaks="3 months",
minor_breaks="1 month")
I've quit using MATPLOTLIB for plotting time series data because of this.
However, I thought perhaps there is a better way that I am not aware of.
If there is a better way, please educate me! Thanks!
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Less-tedious-way-to-change-the-x-axis-scale-intervals-with-time-series-data-tp45175.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
I'm trying to learn if there is a better or less tedious way of changing the
x-axis time scale interval size when plotting time series data using
MATPLOTLIB.
To account for all the different x-axis intervals that I may end up using, I
usually do the following imports:
from matplotlib.dates import YearLocator, MonthLocator, WeekdayLocator,
DateFormatter, DayLocator
from matplotlib.dates import MO, TU, WE, TH, FR, SA, SU
Then I specify specific intervals by doing the following:
year = YearLocator()
month = MonthLocator(bymonth=range(1,13), bymonthday=1, interval=1)
week = WeekdayLocator(byweekday=MO) # Every MOnday
day = DayLocator(bymonthday=range(1,32), interval=1)
Then apply any of the above formats by doing:
axes.xaxis.set_major_locator(year)
axes.xaxis.set_major_locator(month)
I find all that above too tedious since I may then decide to change the
intervals to something different to experiment.
With R's ggplot2 or Yhat's ggplot, it is very simple and intuitive to change
the x-axis scale interval. You just need to specify the breaks and
minor_breaks interval like so:
scale_x_datetime(labels=date_format("%Y-%m"), breaks="3 months",
minor_breaks="1 month")
I've quit using MATPLOTLIB for plotting time series data because of this.
However, I thought perhaps there is a better way that I am not aware of.
If there is a better way, please educate me! Thanks!
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Less-tedious-way-to-change-the-x-axis-scale-intervals-with-time-series-data-tp45175.html
Sent from the matplotlib - users mailing list archive at Nabble.com.