sns.violinplot(df1) 2.8 Bar chart 饼图 ##bar charttextlbl='A','B','C','D'pencentage=[20,30,10,40]offsets=(0,0.1,0,0.05)plt.pie(pencentage,explode=offsets,labels=textlbl) plt.pie(pencentage, explode=offsets, labels=textlbl) 2.9 Grouped bar chart 分组条形图 分组条形图可以先...
s.plot(kind='bar',color ='k',grid = True,alpha = 0.5,ax = axes[0])#ax参数 → 选择第几个子图#单系列柱状图方法一:plt.plot(kind='bar/barh') # dataframe里面如果有标签的话,默认以标签作为横坐标df.plot(kind='bar',ax = axes[1],grid = True,colormap='Reds_r')#多系列柱状图df.plot...
df.plot(kind='bar',ax=axes[2],grid=True,colormap='Blues_r',stacked=True,edgecolor='k') 1. –> 输出的结果为: ④ 横向柱状图:df.plot.barh()/df.plot(kind = 'barh') df.plot.barh(ax=axes[3],grid=True,stacked=True,colormap='BuGn_r',edgecolor='k') #df.plot(k...
# 单系列柱状图方法一:plt.plot(kind='bar/barh') df.plot(kind='bar',ax = axes[1],grid = True,colormap='Reds_r') # 多系列柱状图 df.plot(kind='bar',ax = axes[2],grid = True,colormap='Blues_r',stacked=True) # 多系列堆叠图 # stacked → 堆叠 df.plot.barh(ax= axes[3],gri...
plot(kind='bar', stacked=True) plt.show() 输出如图所示。从图中可以对比五个城市2002年到2014年的商品房价信息,并采用不同颜色进行区分。 如果想对比不同子图,可以利用参数subplots绘制DataFrame中每个序列对应的子图。核心代码如下: 代码语言:javascript 复制 data.plot(color='y', kind='barh', subplots=...
34、条形图 (Bar Chart) 条形图是基于计数或任何给定指标可视化项目的经典方式。在下面的图表中,我为每个项目使用了不同的颜色,但您通常可能希望为所有项目选择一种颜色,除非您按组对其进行着色。 颜色名称存储在下面代码中的all_colors中。您可以通过在plt.plot()中设置颜色参数来更改条的颜色。
colorbar=plt.colorbar()colorbar.set_label('Color Intensity')# 保存图像(可选) # plt.savefig('complex_scatter_plot.png')# 显示图像 plt.show() 上面代码创建了一个复杂的散点图,其中包含两个不同的数据系列,每个系列都具有不同的颜色、标记和大小。通过使用cmap函数,可以改变数据点的颜色映射。
df.plot(kind='pie', subplots=True, figsize=(8, 8)) plt.title("Pie Chart of Vehicle Class - Bad") plt.ylabel("") plt.show() 33. 树形图 (Treemap) 树形图类似于饼图,它可以更好地完成工作而不会误导每个组的贡献。 注:需要安装 squarify 库 # pip install squarify import squarify # Impor...
prettyplotlib Wikipedia: Chartjunk matplotlibduftedufte withmatplotx.show_bar_values() The right plot is created with importmatplotlib.pyplotaspltimportmatplotxlabels=["Australia","Brazil","China","Germany","Mexico","United\nStates"]vals=[21.65,24.5,6.95,8.40,21.00,8.55]xpos=range(len(vals))...
:bar_chart: Save matplotlib figures as TikZ/PGFplots for smooth integration into LaTeX. - nschloe/tikzplotlib