import pandas as pd #读取天气数据 df = pd.read_csv('myweather.csv',encoding='utf-8') print(df.head()) #堆叠柱状图 stacked=True df.plot.bar(stacked=True, x='month',figsize=(12,6), column=['tempmax','tempmin']) # 普通多列柱状图
如下使用plot.bar() 函数做各个区域销售额的柱形图,由图可以看出华南区域的销售额最高,西南区域的销售...
df.plot.bar() # 柱状图 df.plot.barh() # 横向柱状图 (条形图) df.plot.hist() # 直方图 df.plot.box() # 箱形图 df.plot.kde() # 核密度估计图 df.plot.density() # 同 df.plot.kde() df.plot.area() # 面积图 df.plot.pie() # 饼图 df.plot.scatter() # 散点图 df.plot.hexbi...
plt.plot(x1, 'bo', markersize=20) plt.plot(x2, 'ro', ms=10,) plt.show() 1. 2. 3. 4. 5. 6. 7. 8. 9. 七、使用subplot()绘制子图 1. 代码实例1:通过plt的subplot绘制子图 import numpy as np import pandas as pd import matplotlib.pyplot as plt # 画第1个子图:折线图 x=np.ar...
df3.plot(x="A", y="B"); 其他图像 plot() 支持很多图像类型,包括bar, hist, box, density, area, scatter, hexbin, pie等,下面我们分别举例子来看下怎么使用。 bar df.iloc[5].plot(kind="bar"); 多个列的bar: df2 = pd.DataFrame(np.random.rand(10, 4), columns=["a", "b", "c", ...
使用示例:Python Pandas 数据可视化-CJavaPy 参考文档: Python Pandas 绘制图表 pandas.DataFrame.plot — pandas 2.1.4 documentation pandas.DataFrame.plot.bar — pandas 2.1.4 documentation pandas.DataFrame.hist — pandas 2.1.4 documentation pandas.DataFrame.plot.scatter — pandas 2.1.4 documentation ...
df.plot.barh(stacked=True) 运行结果如下: 三、直方图 可以使用plot.hist()方法绘制直方图。我们可以指定数量。 importpandasaspd importnumpyasnp df = pd.DataFrame({'a':np.random.randn(1000)+1,'b':np.random.randn(1000),'c':np.random.randn(1000) -1,'d':np.random.randn(1000) -2}, colu...
#导入pandas库import pandas as pd #生成一个Seriess=pd.Series([1,3,3,4], index=list('ABCD')) #括号内不指定图表类型,则默认生成直线图s.plot()#条形图 s.plot(kind='bar')#水平条形图 s.plot.barh()#饼图 s.plot.pie()#直方图 s.plot.hist()#密度图 import numpy as np#生成一列随机数...
Pandas 是一个用于数据处理和分析的流行库,它提供了一些内置的可视化功能,通常基于 Matplotlib 这个底层库。 绘制线图: df['column_name'].plot(kind='line') 绘制柱状图: df['column_name'].plot(kind='bar') 绘制散点图: df.plot(x='x_column', y='y_column', kind='scatter') ...
#导入pandas库import pandasaspd#生成一个Seriess=pd.Series([1,3,3,4], index=list('ABCD')) #括号内不指定图表类型,则默认生成直线图s.plot() #条形图s.plot(kind='bar') #水平条形图s.plot.barh() #饼图s.plot.pie() #直方图s.plot.hist() ...