Line colour of 3D parametric curve in python's matplotlib.pyplot

后端 未结 2 1143
忘了有多久
忘了有多久 2020-12-05 07:39

I\'ve been googling quite some time with no success ... maybe my keywords are just lousy. Anyway, suppose I have three 1D numpy.ndarrays of the same length I\'d

2条回答
  •  失恋的感觉
    2020-12-05 08:18

    You can plot every line segment separately, as shown below. This just loops over 6 predefined colors, since @askewchan's answer already demonstrates well how to use a colormap.

    cols = 'rgbcmy'
    
    for i in range(len(x)-1):
        ax.plot(x[i:i+2], y[i:i+2], z[i:i+2], color=cols[i%6])
    

    enter image description here

提交回复
热议问题