Say I have data indexed by date time (pd.Timestamp
type), but I know for certain that between certain times each day, there is no data (financial data for example), and I would like to plot data over several days but I want to skip the night times and only draw the day times, so that from one day to the next there isn't a huge gap (of night time) on the x-axis. Is it possible to do that?
CodePudding user response:
You can use the same approach as in this answer for VegaLite (
This is what it would have looked like on a temporal axis, note the long connecting lines without dots which are the night periods:
alt.Chart(pd.DataFrame(records), width=650).mark_line(point=True).encode(
x=alt.X('yearmonthdatehours(Date):T', axis=alt.Axis(labelAngle=-45)),
y=alt.Y('Close', scale=alt.Scale(zero=False))
)