I am trying to plot time-series data in Python using ggplot and am unable to fix the scale.
Here's my most recent effort--first I set the desired max and min values of the x axis as xmin and xmax:
xmin=pd.to_datetime('2011-04-01')
xmax=pd.to_datetime('2011-08-01')
Then, from dataframe fishdf I try to plot my time variable ('tottime'--the x-axis) against a numeric variable ('rx', the y-axis):
fig=(ggplot(fishdf,aes('tottime','rx')) + \
geom_line() + \
geom_point() + \
ggtitle(PIT) + \
scale_x_date(breaks='7 days',
labels=date_format('%m -%d'),
limits=(xmin,xmax))) + \
scale_y_continuous(limits=(0,235))
outfig= r"C:\a\Projects\Shad Telemetry\Connecticut River\CumDat\Python\figs\%s.png"%(PIT)
ggsave(fig,outfig)
This works fine when I don't include the limits= command, but with the limits I get an error
TypeError: a float is required
I have tried various ways of setting/formatting the xmin and xmax, but can't seem to get this to work. Is there a simple solution? I have seen related questions elsewhere but the answers don't seem to work for me (or there are no answers?)