I'm trying to plot a 3D plot from an array p
. However, I get an error. What's the reason for it and how can I overcome this?
Code
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
mpl.rcParams['legend.fontsize'] = 10
fig = plt.figure()
ax = fig.gca(projection='3d')
x=p[:, 0]
y=p[:, 1],
z=p[:, 2],
ax.plot(x, y, z)
ax.legend()
plt.show()
Error
Traceback (most recent call last):
File "<ipython-input-51-6e9ef1b4241b>", line 11, in <module>
ax.plot(x, y, z)
File "C:\Users\Ramdayal\Anaconda3\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line 1537, in plot
lines = Axes.plot(self, xs, ys, *args[argsi:], **kwargs)
File "C:\Users\Ramdayal\Anaconda3\lib\site-packages\matplotlib\__init__.py", line 1897, in inner
return func(ax, *args, **kwargs)
File "C:\Users\Ramdayal\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py", line 1406, in plot
for line in self._get_lines(*args, **kwargs):
File "C:\Users\Ramdayal\Anaconda3\lib\site-packages\matplotlib\axes\_base.py", line 407, in _grab_next_args
for seg in self._plot_args(remaining, kwargs):
File "C:\Users\Ramdayal\Anaconda3\lib\site-packages\matplotlib\axes\_base.py", line 360, in _plot_args
raise ValueError('third arg must be a format string')
ValueError: third arg must be a format string