0

他のすべての迷惑な理解しにくい投稿に続いて、リストがあります。

[0,1,4,3,2,4,2,1,0]

それぞれに色を付けたい

cmap = mpl.colors.ListedColormap([[1,0,0],[0,0,1],[0,1,0],[1,1,0],[0,1,1]])

赤、青、緑、黄、水色の色が得られます。

私が望むのは、色が赤から始まり青で終わり、他の色がそれらの色の間にあることです.

私はおそらく同じような方法でそれを行うことができるでしょうが、ある種の方程式を使用してこれよりも良い方法があると思いますか?

4

1 に答える 1

0

You can fake it. Say you want to the first third of the line in red, the next in blue and the next in green.

You need to create 3 separate lines in your data. You need three lines that look like:

[0,1,4,None,None,None,None,None,None]
[None,None,None,3,2,4,None,None,None]
[None,None,None,None,None,None,2,1,0]

The lines are padded with Nones to make it look like matplotlib is plotting in a continuous line. Then you plot each of the lines and tell matplotlib what colour you want

于 2013-02-23T13:12:42.383 に答える