2016-05-04 8 views
1

私はサブプロット上にプロットしたいデータのリストを持っています。それから私は色の異なるセットでlableableにしたいです。これは、次の画像生成matplotlibを使ってylableに複数の色をプロットする方法は?

import matplotlib.pyplot as plt 
plt.plot([1,2,3,4]) 
plt.ylabel('yellow red blue') 
plt.show() 

: - - :下に簡単なコード例を参照して得られた画像ylableで example figure

「は黄色、赤、青」およびブラック色の全てと命名されています。しかし、このラベルは次のように色付けしたいと思います: -

黄色、 赤色、赤色 、青色の青色です。

matplotlibで可能ですか?

答えて

1

いいえこれは、単一のテキストオブジェクトでは実行できません。手動で三つの異なるラベル、すなわち:

import matplotlib.pyplot as plt 
plt.plot([1, 2, 3, 4]) 
ax = plt.gca() 
ax.text(-0.1, 0.4, 'yellow', color='yellow', rotation=90, transform=ax.transAxes) 
ax.text(-0.1, 0.5, 'red', color='red', rotation=90, transform=ax.transAxes) 
ax.text(-0.1, 0.6, 'blue', color='blue', rotation=90, transform=ax.transAxes) 
plt.show() 

enter image description here

を追加することができます
関連する問題