marker='<',label='销售额')plt.show()柱形图:df.plot(x='销售地区',y='销售额',kind='bar'...
- 然后调用.plot(kind='bar'),通过指定x='A'绘制A的柱状图 - 最后调用.plot(kind='pie'),通过指...
DataFrame.plot.bar() 或者 DataFrame.plot(kind=‘bar’) 1. 基本用法 df2 = pd.DataFrame(np.random.rand(10, 4), columns=["a", "b", "c", "d"]) df2.plot.bar() 1. 2. 2. 参数stacked=True,生成堆积条形图 df2.plot.bar(stacked=True) 1. 3. 使用barh,生成水平条形图 df2.plot.ba...
调用plot函数时,可指定x轴数据对应的列名。 同时也能指定y轴数据对应的列或多列。例如df.plot(x='日期', y='销售额')可绘制销售额随日期的变化图。可以设置颜色参数来为图表中的元素指定颜色。如df.plot(kind='bar', color='red')可让柱状图为红色。还能通过label参数为图表中的线条或柱子添加标签。这些...
x : label or position, default None#指数据列的标签或位置参数 y : label, position or list of label, positions, default None kind : str#绘图类型 ‘line’ : line plot (default)#折线图 ‘bar’ : vertical bar plot#条形图。stacked为True时为堆叠的柱状图 ...
y : label or position, default None kind : str ‘line’ : line plot (default)#折线图 ‘bar’ : vertical bar plot#条形图 ‘barh’ : horizontal bar plot#横向条形图 ‘hist’ : histogram#柱状图 ‘box’ : boxplot#箱线图 ‘kde’ : Kernel Density Estimation plot#Kernel 的密度估计图,主要...
‘barh’ : horizontal bar plot ‘hist’ : histogram ‘box’ : boxplot ‘kde’ : Kernel Density Estimation plot ‘density’ : same as ‘kde’ ‘area’ : area plot ‘pie’ : pie plot 指定画图的类型,是线形图还是柱状图等 label 添加标签 ...
plt.bar(name, group['count'], label=name, align='center') plt.legend() plt.show() 没有可以传递给df.plot的参数,它可以为单个列以不同的方式对条形图进行着色。 由于不同列的条形图颜色不同,一个选项是在绘图之前转置数据框, ax = df.T.plot(kind='bar', label='index', colormap='Paired')...
import matplotlib.pyplot as plt # 绘制折线图 df.plot(kind='line') plt.show() # 绘制柱状图 df.plot(kind='bar') plt.show() # 绘制散点图 df.plot(kind='scatter', x='A', y='B') plt.show() 使用Matplotlib绘图 python # 绘制折线图 plt.plot(df['A'], label='A') plt.plot(df[...
方法描述DataFrame.plot([x, y, kind, ax, ….])DataFrame plotting accessor and methodDataFrame.plot.area([x, y])面积图Area plotDataFrame.plot.bar([x, y])垂直条形图Vertical bar plotDataFrame.plot.barh([x, y])水平条形图Horizontal bar plotDataFrame.plot.box([by])箱图BoxplotDataFrame.plot....