matplotlib_相关设置

pyplot.xlim([xmin],[xmax]                                    >>>设置或返回x轴显示范围

pyplot.ylim([ymin],[ymax])                                     >>>设置或返回y轴显示范围

pyplot.xlabelxlabelfontdict = Nonelabelpad = None** kwargs    >>>设置x轴的标签

labelpad:标签与x轴的距离
text属性

pyplot.ylabelylabelfontdict = Nonelabelpad = None** kwargs    >>>设置x轴的标签

labelpad:标签与y轴的距离
text属性

pyplot.grid(b=Nonewhich='major'axis='both'**kwargs)        >>>配置网格线

b:是否显示网格线,如果该方法添加了任何参数,该属性默认为True
which:{'major','minor','both'}要应用的网格线
axis:{'both','x','y'}要应用的轴
linestyle:线条风格
color:线条颜色
linewidth:线条宽度
alpha:网格线透明度

pyplot.axhline(y=0xmin=0xmax=1**kwargs)       >>>绘制平行于X轴的水平线

y:水平线的y坐标
xmin:0表示从图最左边开始,介于0-1之间
xmax:1表示在图最右边结束,介于0-1之间
c:参考线的颜色
ls:参考线的线条风格
lw:参考线的线条宽度
lable:参考线文本标签

pyplot.axvline(x=0, ymin=0, ymax=1**kwargs)       >>>绘制平行于Y轴的水平线

x:水平线的x坐标
ymin:0表示从图最下边开始,介于0-1之间
ymax:1表示在图最上边结束,介于0-1之间
c:参考线的颜色
ls:参考线的线条风格
lw:参考线的线条宽度
lable:参考线文本标签

pyplot.axvspan(xminxmax,ymin=0ymax=1,  **kwargs      >>>绘制垂直于X轴的参考区域

xmin:参考区域x轴起点位置
xmax:参考区域x轴终点位置
ymin:0表示从图最下边开始,介于0-1之间
ymax:1表示在图最上边结束,介于0-1之间

pyplot.axhspan(yminymax,xmin=0xmax=1,  **kwargs      >>>绘制垂直于Y轴的参考区域

ymin:参考区域y轴起点位置
ymax:参考区域y轴终点位置
xmin:0表示从图最左边开始,介于0-1之间
xmax:1表示在图最右边结束,介于0-1之间

pyplot.annotatesxy* args** kwargs      >>>添加图形内容细节的指向形注释文本

s:注释文本
xy:要注释的点(x,y)
xytext:放置文本的位置(x,y)
color:注释文本颜色
weigth:注释文本的字体粗细风格
arrowprops:箭头的属性字典
'''
arrowstyle:箭头风格
'-'	    None
'->'	head_length=0.4,head_width=0.2
'-['	widthB=1.0,lengthB=0.2,angleB=None
'|-|'	widthA=1.0,widthB=1.0
'-|>'	head_length=0.4,head_width=0.2
'<-'	head_length=0.4,head_width=0.2
'<->'	head_length=0.4,head_width=0.2
'<|-'	head_length=0.4,head_width=0.2
'<|-|>'	head_length=0.4,head_width=0.2


connectionstyle:连接风格
'angle'	angleA=90, angleB=0, rad=0.0
'angle3'	angleA=90, angleB=0
'arc'	angleA=0, angleB=0, armA=None, armB=None, rad=0.0
'arc3'	rad=0.0
'bar'	armA=0.0, armB=0.0, fraction=0.3, angle=None

color:颜色
'''
bbox:文本所在框的样式,字典
'''
boxstyle:框的样式,round,square
ec:
fc:
'''

pyplot.textxysfontdict = Nonewithdash = False** kwargs      >>>添加图形内容细节的无指向形注释文本

x:注释文本所在的横坐标
y:注释文本所在的纵坐标
s:注释文本
weight:注释文本内容的粗细风格
color:注释文本的字体颜色
rotation:顺时针旋转多少度
text属性

pyplot.xticksticks = Nonelabels = None** kwargs )    >>>获取或设置当前刻度线位置和x轴标签

ticks:应该放置刻度的位置列表
labels:标签列表
text属性

pyplot.yticksticks = Nonelabels = None** kwargs     >>>获取或设置当前刻度线位置和y轴标签

ticks:应该放置刻度的位置列表
labels:标签列表
text属性

pyplot.titlelabelfontdict = Noneloc ='center'pad = None** kwargs    >>>设置图形内容的标题

label:标题文本
fontdict :控制标题文本外观的字典
'''
默认:
{'fontsize': rcParams['axes.titlesize'],
 'fontweight' : rcParams['axes.titleweight'],
 'verticalalignment': 'baseline',
 'horizontalalignment': loc}
'''
loc : {'center','left','right'},str,optional 要设置的标题,默认为“中心”
pad:坐标与顶部轴的偏移量
text属性

pyplot.legend* args** kwargs     >>>在轴上放置图例

handles:自定义内容
loc:位置;,str  or int
bbox_to_anchor:图例定位(x,y),左上角的xy轴坐标
'''
'best'	        0
'upper right'	1
'upper left'	2
'lower left'	3
'lower right'	4
'right'	        5
'center left'	6
'center right'	7
'lower center'	8
'upper center'	9
'center'	    10
'''

pyplot.table** kwargs )    >>>向统计图形添加表格

cellText:表格的数值,按行分组,格式与DataFrame一致
cellColours:表格的数值的颜色,格式与cellText一致
cellLoc:表格中数据对齐方式,默认right,  可选left  center
colWidths:表格每列的宽度,数组
rowLabels:行名
rowColours:行名所在单元格的颜色
rowLoc:行名对齐方式,默认left 可选right  center
colLabels:列名
colColours:列名所在单元格的颜色
colLoc:列名对齐方式,默认center 可选right  left
loc:位置,默认'bottom'

pyplot.autoscaleenable = Trueaxis ='both'tight = None )    >>>调整坐标轴范围

enable:是否开启自适应调整
axis:x,y,both
tight:是否将视图限制设置为数据限制

保存

pyplot.savefig* args** kwargs 

fname:文件路径
dpi:像素

解决中文乱码

plt.rcParams['font.sans-serif']=['SimHei']  # 用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False  # 用来正常显示负号

text属性

PropertyDescription
agg_filtera filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array
alphafloat
animatedbool
backgroundcolorcolor
bboxdict with properties for patches.FancyBboxPatch
clip_boxmatplotlib.transforms.Bbox
clip_onbool
clip_path{ (path.Pathtransforms.Transform), patches.Patch, None }
colorcolor
containscallable
figureFigure
fontfamily{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
fontname{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
fontpropertiesfont_manager.FontProperties
fontsize{size in points, 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}
fontstretch{a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'}
fontstyle{'normal', 'italic', 'oblique'}
fontvariant{'normal', 'small-caps'}
fontweight{a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'}
gidstr
horizontalalignment{'center', 'right', 'left'}
in_layoutbool
labelobject
linespacingfloat (multiple of font size)
multialignment{'left', 'right', 'center'}
path_effectsAbstractPathEffect
pickerNone or bool or float or callable
position(float, float)
rasterizedbool or None
rotation{angle in degrees, 'vertical', 'horizontal'}
rotation_mode{None, 'default', 'anchor'}
sketch_params(scale: float, length: float, randomness: float)
snapbool or None
textstring or object castable to string (but None becomes '')
transformTransform
urlstr
usetexbool or None
verticalalignment{'center', 'top', 'bottom', 'baseline', 'center_baseline'}
visiblebool
wrapbool
xfloat
yfloat
zorderfloat

官方文档:https://matplotlib.org/api/pyplot_summary.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值