0
インデックスを参照して点が色付けされている変数をプロットすることができません。私が最終的に望むのは、(次の点に接続する)各点の線分を特定の色にすることです。私はMatplotlib
とpandas
の両方で試しました。各メソッドは異なるエラーをスローします。Pythonで複数色の線をプロットしようとするとエラーが発生する
トレンドラインの生成:
0 labels
0 0.000000 2
1 0.598472 2
2 -0.958924 1
3 0.938000 2
4 -0.544021 1
:私たちの最終的なデータセットを生成する
sinned['labels'] = np.where((sinned < 0), 1, 2)
print(sinned)
:だから今
datums = np.linspace(0,10,5)
sinned = np.sin(datums)
plt.plot(sinned)
を、私たちは、ラベルの新しい列を生成します
そして今、プロットの試みのために:エラーになり
plt.plot(sinned[0], c = sinned['labels'])
:length of rgba sequence should be either 3 or 4
私も:-/
[パイソン:どのように異なる色で1本のラインをプロットする]の可能な重複(http://stackoverflow.com/questions/17240694/python-how-to-plot-one-line -in-different-colours) – ImportanceOfBeingErnest
この質問を見る:http://stackoverflow.com/questions/17240694/python-how-to-plot-one-line-in-different-colorsまた、matplotlib [example色付けラインについて](http://matplotlib.org/examples/pylab_examples/multicolored_line.html) – ImportanceOfBeingErnest
@ImportanceOfBeingErnest今、あなたが今提案した質問を通過するだけです。 –