My x-axis being time in hours and minutes, I am not able to plot in intervals of 1 hour, by default it is plotting in interval of 5 hours.
Here x-axis is "newtime" which is in the format below
00:00:00
00:15:00
00:30:00
00:45:00
01:00:00
01:15:00
01:30:00
01:45:00
02:00:00
02:15:00
02:30:00
.
.
.
23:45:00
First tried like this but got error
ggplot(data = temp1)+
aes(x="newtime", y="SALES" ,color="newdate")+
geom_line()+
labs(x = "Time", y = "SALES", title = s)+
scale_x_datetime(breaks="1 hour")
TypeError: Discrete value supplied to continuous scale
Second tried like this but got error
ggplot(data = temp1)+
aes(x="newtime", y="SALES" ,color="newdate")+
geom_line()+
labs(x = "Time", y = "SALES", title = s)+
scale_x_continuous(breaks=range(0,24,1))
TypeError: Discrete value supplied to continuous scale
Third tried like this but got error
ggplot(data = temp1)+
aes(x="newtime", y="SALES" ,color="newdate")+
geom_line()+
labs(x = "Time", y = "SALES", title = s)+
scale_x_discrete(breaks=range(0,24,1))
TypeError: Continuous value supplied to discrete scale
ggplot(data = temp1)+
aes(x="newtime", y="SALES" ,color="newdate")+
geom_line()+
labs(x = "Time", y = "SALES", title = s)
The entire code is here
import pandas as pd
from plotnine import *
import numpy as np
temp1=pd.read_excel("C:\\Users\\Desktop\\2019\\DATA.xlsx")
a=temp1.Date.astype(str)
temp1["newdate"]=a
b=pd.to_timedelta(temp1.Hour, unit='h') + pd.to_timedelta(temp1.Min,
unit='m')
temp1["newtime"]=b
v=(
ggplot(data = temp1)+
aes(x="newtime", y="SALES" ,color="newdate")+
geom_line()+
labs(x = "Time", y = "SALES", title = "s")+
scale_x_datetime(breaks="1 hour")
)
print(v)
And the data is in the link link
I'm trying to plot something like this !https://i.stack.imgur.com/xOMRE.jpg. I'm getting plot like this !https://i.stack.imgur.com/Mr9cb.jpg.