How to plot a multicolored curve using a single plot command in matplotlib

后端 未结 2 621
我在风中等你
我在风中等你 2021-01-21 06:30

If I understand correctly, the function:

matplotlib.pyplot.plot(x, y)

plots len(x)-1 separate line segments - one going from (x[0], y[0]) to (x

2条回答
  •  被撕碎了的回忆
    2021-01-21 06:52

    If you implement a colorbar, something similar to this, then you should be able to do it in one line. The trick may be to pick a colorscale that changes on the order of your line segments.

提交回复
热议问题