I'm trying to visualize a dataset in python by matplotlib. I need points connected to each other by lines. I also have a colour pattern to show differences in changes. However, I need a coloured line instead of coloured points in 3D Plotter. Here is my code:
divnorm = TwoSlopeNorm(vmin=-3., vcenter=0, vmax=5)
color_array = [get_color(v) for v in vario[1:200]]
ax.plot3D(coordXList[:199], coordYList[:199], alt[1:200],c=color_array, cmap='RdYlBu_r') #, cmap='RdYlBu_r')
im = ax.scatter3D(coordXList[:199], coordYList[:199], alt[1:200],
norm=divnorm, c=color_array, cmap='RdYlBu_r')
ax.set_xlabel('X Axis')
ax.set_ylabel('Y Axis')
ax.set_zlabel('Z Axis')
ax.view_init(elev=10., azim=45)
plt.show()
Main()
I can visualize the data if use 'k' instead of c=color_array, cmap='RdYlBu_r'
but when I try to other cmap, I get
Traceback (most recent call last):
File "C:/Users/HP/PycharmProjects/GPS reading/thermal line_PL (1).py", line 136, in <module>
ax.plot3D(coordXList[:199], coordYList[:199], alt[1:200],c=color_array, cmap='RdYlBu_r' ) #, cmap='RdYlBu_r')
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line 1471, in plot
lines = super().plot(xs, ys, *args, **kwargs)
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\axes\_axes.py", line 1743, in plot
lines = [*self._get_lines(*args, data=data, **kwargs)]
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\axes\_base.py", line 273, in __call__
yield from self._plot_args(this, kwargs)
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\axes\_base.py", line 419, in _plot_args
for j in range(max(ncx, ncy))]
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\axes\_base.py", line 419, in <listcomp>
for j in range(max(ncx, ncy))]
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\axes\_base.py", line 312, in _makeline
seg = mlines.Line2D(x, y, **kw)
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\lines.py", line 390, in __init__
self.update(kwargs)
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\artist.py", line 996, in update
raise AttributeError(f"{type(self).__name__!r} object "
AttributeError: 'Line2D' object has no property 'cmap'
Process finished with exit code 1
Thanks