python plot画图函数_详解pandas.DataFrame.plot() 画图函数
首先看官网的DataFrame.plot( )函数
DataFrame.plot(x=None, y=None, kind='line', ax=None, subplots=False,
sharex=None, sharey=False, layout=None,figsize=None,
use_index=True, title=None, grid=None, legend=True,
style=None, logx=False, logy=False, loglog=False,
xticks=None, yticks=None, xlim=None, ylim=None, rot=None,
xerr=None,secondary_y=False, sort_columns=False, **kwds)
参数详解如下:
Parameters:
x : label or position, default None#指数据框列的标签或位置参数
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 的密度估计图,主要对柱状图添加Kernel 概率密度线
‘density' : same as ‘kde'
‘area' : area plot#不了解此图
‘pie' : pie plot#饼图
‘scatter' : scatter plot#散点图 需要传入columns方向的索引
‘hexbin' : hexbin plot#不了解此图
ax : matplotlib axes object, default None#**子图(axes, 也可以理解成坐标轴) 要在其上进行绘制的matplotlib subplot对象。如果没有设置,则使用当前matplotlib subplot**其中,变量和函数通过改变figure和axes中的元素(例如:title,label,点和线等等)一起描述figure和axes,也就是在画布上绘图。
subplots : boolean, default False#判断图片中是否有子图
Make separate subplots for each column
sharex : boolean, default True if ax is None else False#如果有子图,子图共x轴刻度,标签
In case subplots=True, share x axis and set some x axis labels to invisible; defaults to True if ax is None otherwise False if an ax is passed in; Be aware, that passing in both an ax and sharex=True will alter all x axis labels for all axis in a figure!
sharey : boolean, default False#如果有子图,子图共y轴刻度,标签
In case subplots=True, share y axis and set some y axis labels to invisible
layout : tuple (optional)#子图的行列布局
(rows, columns) for the layout of subplots
figsize : a tuple (width, height) in inches#图片尺寸大小
use_index : boolean, default True#默认用索引做x轴
Use index as ticks for x axis
title : string#图片的标题用字符串
Title to use for the plot
grid : boolean, default None (matlab style default)#图片是否有网格
Axis grid lines
legend : False/True/'reverse'#子图的图例,添加一个subplot图例(默认为True)
Place legend on axis subplots
style : list or dict#对每列折线图设置线的类型
matplotlib line style per column
logx : boolean, default False#设置x轴刻度是否取对数
Use log scaling on x axis
logy : boolean, default False
Use log scaling on y axis
loglog : boolean, default False#同时设置x,y轴刻度是否取对数
Use log scaling on both x and y axes
xticks : sequence#设置x轴刻度值,序列形式(比如列表)
Values to use for the xticks
yticks : sequence#设置y轴刻度,序列形式(比如列表)
Values to use for the yticks
xlim : 2-tuple/list#设置坐标轴的范围,列表或元组形式
ylim : 2-tuple/list
rot : int, default None#设置轴标签(轴刻度)的显示旋转度数
Rotation for ticks (xticks for vertical, yticks for horizontal plots)
fontsize : int, default None#设置轴刻度的字体大小
Font size for xticks and yticks
colormap : str or matplotlib colormap object, default None#设置图的区域颜色
Colormap to select colors from. If string, load colormap with that name from matplotlib.
colorbar : boolean, optional #图片柱子
If True, plot colorbar (only relevant for ‘scatter' and ‘hexbin' plots)
position : float
Specify relative alignments for bar plot layout. From 0 (left/bottom-end) to 1 (right/top-end). Default is 0.5 (center)
layout : tuple (optional) #布局
(rows, columns) for the layout of the plot
table : boolean, Series or DataFrame, default False #如果为正,则选择DataFrame类型的数据并且转换匹配matplotlib的布局。
If True, draw a table using the data in the DataFrame and the data will be transposed to meet matplotlib's default layout. If a Series or DataFrame is passed, use passed data to draw a table.
yerr : DataFrame, Series, array-like, dict and str
See Plotting with Error Bars for detail.
xerr : same types as yerr.
stacked : boolean, default False in line and
bar plots, and True in area plot. If True, create stacked plot.
sort_columns : boolean, default False # 以字母表顺序绘制各列,默认使用前列顺序
secondary_y : boolean or sequence, default False ##设置第二个y轴(右y轴)
Whether to plot on the secondary y-axis If a list/tuple, which columns to plot on secondary y-axis
mark_right : boolean, default True
When using a secondary_y axis, automatically mark the column labels with “(right)” in the legend
kwds : keywords
Options to pass to matplotlib plotting method
Returns:axes : matplotlib.AxesSubplot or np.array of them
1、画图图形
import pandas as pd
from pandas import DataFrame,Series
df = pd.DataFrame(np.random.randn(4,4),index = list('ABCD'),columns=list('OPKL'))
df
Out[4]:
O P K L
A -1.736654 0.327206 -1.000506 1.235681
B 1.216879 0.506565 0.889197 -1.478165
C 0.091957 -2.677410 -0.973761 0.123733
D -1.114622 -0.600751 -0.159181 1.041668
注意一下散点图scatter是需要传入两个Y的columns参数的:
传入x,y参数
同时画多个子图,可以设置 subplot = True
2、注意事项:
- 在画图时,要注意首先定义画图的画布:fig = plt.figure( )
- 然后定义子图ax ,使用 ax= fig.add_subplot( 行,列,位置标)
- 当上述步骤完成后,可以用 ax.plot()函数或者 df.plot(ax = ax)
- 在jupternotebook 需要用%定义:%matplotlib notebook;如果是在脚本编译器上则不用,但是需要一次性按流程把代码写完;
- 结尾时都注意记录上plt.show()
到此这篇关于详解pandas.DataFrame.plot() 画图函数的文章就介绍到这了,更多相关pandas.DataFrame.plot( )画图内容请搜索python博客以前的文章或继续浏览下面的相关文章希望大家以后多多支持python博客!
python plot画图函数_详解pandas.DataFrame.plot() 画图函数相关推荐
- python怎么画参数函数图像_详解pandas.DataFrame.plot() 画图函数
首先看官网的DataFrame.plot( )函数 DataFrame.plot(x=None, y=None, kind='line', ax=None, subplots=False, share ...
- python dataframe loc函数_详解pandas DataFrame的查询方法(loc,iloc,at,iat,ix的用法和区别)...
在操作DataFrame时,肯定会经常用到loc,iloc,at等函数,各个函数看起来差不多,但是还是有很多区别的,我们一起来看下吧. 首先,还是列出一个我们用的DataFrame,注意index一列 ...
- python中的iloc函数_详解pandas中利用DataFrame对象的.loc[]、.iloc[]方法抽取数据
pandas的DataFrame对象,本质上是二维矩阵,跟常规二维矩阵的差别在于前者额外指定了每一行和每一列的名称.这样内部数据抽取既可以用"行列名称(对应.loc[]方法)",也 ...
- python grid函数_详解numpy中的meshgrid函数用法
numpy中的meshgrid函数的使用 numpy官方文档meshgrid函数帮助文档https://docs.scipy.org/doc/numpy/reference/generated/num ...
- python替换缺失值_详解Pandas 处理缺失值指令大全
前言 运用pandas 库对所得到的数据进行数据清洗,复习一下相关的知识. 1 数据清洗 1.1 处理缺失数据 对于数值型数据,分为缺失值(NAN)和非缺失值,对于缺失值的检测,可以通过Python中 ...
- python read_excel 参数_详解pandas库pd.read_excel操作读取excel文件参数整理与实例
详解pandas库pd.read_excel操作读取excel文件参数整理与实例 来源:中文源码网 浏览: 次 日期:2019年11月5日 详解pandas库pd.read_excel操作 ...
- python3中input输入浅谈_详解Python3中的 input() 函数
详解Python3中的 input() 函数 一.知识介绍: 1.input() 函数,接收任意输入,将所有输入默认为字符串处理,并返回字符串类型: 2.可以用作文本输入,如用户名,密码框的值输入: ...
- php seekdir,C++_详解C语言中telldir()函数和seekdir()函数的用法,C语言telldir()函数:取得目录流 - phpStudy...
详解C语言中telldir()函数和seekdir()函数的用法 C语言telldir()函数:取得目录流的读取位置头文件: #include 定义函数: off_t telldir(DIR *dir ...
- python while函数_详解python while 函数及while和for的区别
1.while循环(只有在条件表达式成立的时候才会进入while循环) while 条件表达式: pass while 条件表达式: pass else: pass 不知道循环次数,但确定循环条件的时 ...
- python中index函数_详解python中的index函数用法
1.函数的创建 def fun(): #定义 print('hellow') #函数的执行代码 retrun 1 #返回值 fun() #执行函数 2.函数的参数 普通参数 :要按照顺序输入参数 de ...
最新文章
- 包(package)
- JZOJ 5628. 【NOI2018模拟4.4】Travel
- oracle 数据库问题,ORACLE数据库常见问题汇总,oracle常见问题汇总
- boost::hana::experimental::type_name用法的测试程序
- 好看的按钮组件_这个发光的外骨骼盔甲是什么?为什么它如此好看!
- 1+X web中级 Laravel学习笔记——Laravel中的路由
- 官宣!又一所新大学来了!
- Java并发编程-ReentrantLock
- android随机运算器开发小结1
- c语言i o编程,【linux】基本I/O操作标准I/O操作(c语言编程)
- 第一天学习笔记之数组(冒泡排序+二分查找)
- 【mysql知识点总结】
- 如何查看K/3数据库表及字段详细信息
- ubuntu系统下mysql重置密码和修改密码操作
- 用ArcGIS提取HWSD中的土壤单一属性数据
- Hi3559A 开发总结--使用docker
- 【unity 保卫星城】--- 开发笔记07(追踪导弹武器)
- 提升产品创新能力,试试斯坦福大学设计思维模型
- iOS 5G网络判断
- 优缺点 快速扫描 硬盘监测_MHDD快速检测硬盘坏道