首页 > 编程语言 >python pandas.DataFrame.plot( )画图

python pandas.DataFrame.plot( )画图

时间:2023-10-31 13:01:28浏览次数:37  
标签:plot None False python default boolean True pandas

 python pandas.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

 

PyCharm中下列代码不能显示绘图:

import pandas as pd
import numpy as np
from pandas import DataFrame,Series

df = pd.DataFrame(np.random.randn(4,4),index = list('ABCD'),columns=list('OPKL'))
df.plot()

 

添加代码即可:

import matplotlib.pyplot as plt
plt.show()

import pandas as pd
import numpy as np
from pandas import DataFrame,Series

df = pd.DataFrame(np.random.randn(4,4),index = list('ABCD'),columns=list('OPKL'))
df.plot()

import matplotlib.pyplot as plt
plt.show()

 

 

REF

http://www.360doc.com/content/22/1010/10/77611998_1051128181.shtml

 



标签:plot,None,False,python,default,boolean,True,pandas
From: https://blog.51cto.com/emanlee/8103777

相关文章

  • 三维重建 PyQt Python MPR 四视图(横断面,冠状面,矢状面,3D)
    本文实现了PythonMPR的四视图,横断面,冠状面,矢状面,3DMPR(multi-plannerreformation)也称多平面重建,多重面重建是将扫描范围内所有的轴位图像叠加起来再对某些标线标定的重组线所指定的组织进行冠状、矢状位、任意角度斜位图像重组。主要功能:1:实现了所有切面与其他视图光标应该......
  • Python中常用的函数
    1.sorted()函数Python的内置函数sorted()是一种简单而强大的排序工具。它返回一个新的已排序列表,而不会改变原始列表。默认情况下,它按升序排序。2. python数组的基本结构#增加appendA=[1,2,3,4]A.append(5)#在数组末尾追加元素print(A)#删除removepop......
  • Python中的切片操作
    一、切片操作的基本概念1.1切片是什么?切片是Python中一种用于操作序列类型(如列表、字符串和元组)的方法。它通过指定起始索引和结束索引来截取出序列的一部分,形成一个新的序列。1.2切片的语法切片的基本语法为:sequence[start:end:step]其中,sequence表示待切片的序列,start表......
  • python和迭代器区别
    Python列表:它们是否为迭代器 文章目录列表是可迭代对象列表不是迭代器列表与迭代器的区别总结Python列表:它们是否为迭代器在本文中,我们将介绍Python列表和迭代器之间的关系。Python列表是一种常用的数据结构,用于存储多个元素。而迭代器是一种访问集合元素的对象......
  • 代码战场:用Python射击游戏开启程序员的创造之旅
    目录前言代码演示总结前言大家好,我是辣条哥!昨天在家点开好久没打开的游戏菜单,突然看到好久没有玩过的某F,玩了几把发现时代是真的变了!于是今天辣条有感而发写了这么一个简陋的射击类小游戏在这个项目中,我们将使用Python编写一个射击类游戏。这个游戏不仅具有高难度,还可以进行......
  • 【ROS2机器人入门到实战】坐标变换发布监听Python实现
    3.坐标变换发布监听Python实现写在前面当前平台文章汇总地址:ROS2机器人从入门到实战获取完整教程及配套资料代码,请关注公众号<鱼香ROS>获取教程配套机器人开发平台:两驱版|四驱版为方便交流,搭建了机器人技术问答社区:地址fishros.org.cn运行前面安装的jupyter,我们尝试使用代码来操......
  • Python 从在线网站获取当前日期时间
    python3.7获取网络时间_python获取网络时间-CSDN博客#-*-coding:utf-8-*-importdatetimeimporttimeimportntplibimportrequestsdefget_beijing_time():try:url='https://beijing-time.org/'request_result=requests.get(url=url)......
  • python url 网址链接写函数()括号里不能访问显示403
    说明一则奇怪问题。同一个url网址链接,写到函数里就访问失败,写到变量里就可以正常访问。一、文件名test_url.pydefr_http(url): response=requests.get(url,headers=u_headers) print(f"response.status_code={response.status_code}")二、url直接写到调用的函数中,......
  • python编码规范
    遵循良好的编码风格,可以有效的提高代码的可读性,降低出错几率和维护难度。在团队开发中,使用(尽量)统一的编码风格,还可以降低沟通成本。网上有很多版本的编码规范,基本上都是遵循PEP8的规范:PEP0008–StyleGuideforPythonCodeGoogle的Python风格指南PythonGuide......
  • python求pi
    用python计算圆周率PI‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬描述用python......