I am trying to make a 3D scatter plot that has the following axis: Price, Time and Dates. Essentially I want to plot the price vs the time for a single day and then do that for multiple days and stack them on an axis.
Here is the code I have so far:
df=pd.read_csv("C:\\Desktop\\dat.csv")
date= df['date'].unique()
dfd = pd.DataFrame(date)
days= dfd.sort_values(0)
fig= plt.figure()
ax= fig.add_subplot(111, projection= '3d')
xx = np.arange(len(days[0]))
ys = [i+xx+(i*xx)**2 for i in range(len(days[0]))]
colors = cm.rainbow(np.linspace(0, 1, len(ys)))
for d,cc in zip(days[0],colors):
td= df.loc[df['date'] == d]
st= td[['time','price']]
x = st['time']
y = st['price']
x=list(x)
y=list(y)
ax.scatter(x,y,d,color=cc)
plt.show()
The main problem is that x is a list with times and that d is a date. when I run the code matplotlib throws an error saying
ValueError: invalid literal for float(): 9:30:01
The dates are in the following format : 2017.04.12, time format : 9:30:01
I am aware that I can set up tick labels for the date, but how can I handle the time?
How can I plot this 3d plot if the axis indexes contain dates and times?