0

I tried this code. I cannot understand what does it mean by it's strange error ValueError: shape mismatch: objects cannot be broadcast to a single shape

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.dates as dt

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
lstDT=['2017-01-01T09:00:00.000','2017-01-01T09:00:01.000','2017-01-01T09:00:02.000','2017-01-01T09:00:03.000','2017-01-01T09:00:04.000', '2017-01-01T09:00:05.000','2017-01-01T09:00:06.000', '2017-01-01T09:00:07.000','2017-01-01T09:00:08.000', '2017-01-01T09:00:09.000','2017-01-01T09:00:10.000']
lstDT = np.asarray(lstDT, dtype='datetime64[ms]')
lstDT1 = dt.date2num(list(lstDT))
X=np.array(lstDT)
# Y=np.array([1,2,3,4,5,6,7,8,9,10])
Y = [65.2, 65.2, 65.2, 65.2, 65.2, 65.2, 65.2, 65.2, 65.2, 65.2, 65.2]
Y = np.array(Y)
Z=np.array([[1,1,1,1,1,1,1,1,1,1]])
ax.plot_wireframe(X,Y,Z)

plt.show()

If anyone has tried some other way like polygon collection that's also welcome.

Rahul
  • 41
  • 1
  • 7
  • I'm not sure you want a wireframe. Seems you want `plot3d`. What are you expecting to get? – busybear Apr 22 '20 at 13:56
  • Does this answer your question? [matplotlib 3d scatter plot date](https://stackoverflow.com/questions/42677160/matplotlib-3d-scatter-plot-date) – Joe Apr 22 '20 at 14:29
  • https://stackoverflow.com/questions/43380335/python-3d-plot-with-dates – Joe Apr 22 '20 at 14:30
  • @Joe my friend you always come for my help. First of all I appreciate that, seriously. Secondly, https://stackoverflow.com/questions/42677160/matplotlib-3d-scatter-plot-date is comprehensive but is nt exact match, might help. In https://stackoverflow.com/questions/43380335/python-3d-plot-with-dates I am not sure which data he started with so a bit incomprehensible. – Rahul Apr 23 '20 at 05:34
  • The real data is not that important for now. Just create a range of dates using https://matplotlib.org/3.1.0/api/dates_api.html#matplotlib.dates.drange – Joe Apr 23 '20 at 05:40
  • https://matplotlib.org/2.0.2/examples/pylab_examples/date_demo_convert.html – Joe Apr 23 '20 at 05:41
  • https://stackoverflow.com/questions/45896379/converting-a-list-of-datetime-objects-using-drange-to-plot-in-matplotlib-gives-a – Joe Apr 23 '20 at 05:41
  • Still don't understand why I cannot plot time in 3d? – Rahul Apr 23 '20 at 09:40

0 Answers0