我有一个直方图的子图。这个plt.图例在底部创建了一个颜色重复的图例。在这部分子图的截图中
“唤醒”与“睡眠-快速眼动”是同一颜色
{1美元^
如何更改图形和图例的颜色以使它们都是唯一的?在
def create_histogram( grouped, axs, df ):
bin_size = 100
alpha = 0.5
grouped = df.groupby( 'Label' )
bins = np.linspace( df.Capacitor_1.min(), df.Capacitor_1.max(), bin_size )
series = grouped.Capacitor_1
series.plot( kind = 'hist', title = "Capacitor 1", ax = axs[0][0] , bins = bins, alpha = alpha )
...
bins = np.linspace( df.Mag_Z.min(), df.Mag_Z.max(), bin_size )
series = grouped.Mag_Z
series.plot( kind = 'hist', title = "Mag Z", ax = axs[3][2], bins = bins, alpha = alpha )
fig, axs = plt.subplots( nrows = 4, ncols = 3, figsize = ( 20, 40 ) )
fig.subplots_adjust( hspace = .5 )
grouped = df_left.groupby( 'Label' )
create_histogram( grouped, axs, df_left )
plt.legend( bbox_to_anchor = ( 0.98, 0.8 ) )
plt.show()
plot
有一个color
参数。您可以为每列使用不同的颜色。例如@Evert的评论起到了帮助作用
修改了上面的pydef函数:
相关问题 更多 >
编程相关推荐