【发布时间】:2019-03-04 22:23:57
【问题描述】:
这是我的示例,我无法定义不同的条形颜色......由于某种原因,所有颜色都是红色的。
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# initiliaze a dataframe with index and column names
idf = pd.DataFrame.from_items([('A', [1, 2, 3]), ('B', [4, 5, 6]), ('C', 10,
20, 30]), ('D', [14, 15, 16])], orient='index', columns=['x', > 'y', 'z'])
# Plot the clustermap which will be a figure by itself
cax = sns.clustermap(idf, col_cluster=False, row_cluster=True)
# Get the column dendrogram axis
cax_col_dend_ax = cax.ax_col_dendrogram.axes
# Plot the boxplot on the column dendrogram axis
idf.iloc[0,:].plot(kind='bar', ax=cax_col_dend_ax, color = ['r', 'g', 'b'])
# Show the plot
plt.show()
【问题讨论】:
-
使用matplotlib版本
'2.2.2'对我来说效果很好
标签: python pandas matplotlib seaborn