当前位置:网站首页>Matplotlib常用设置
Matplotlib常用设置
2022-07-01 22:50:00 【冷巷(*_*)】
线条颜色和样式
图表的常用设置
matplotlib.pyplot.plot的color参数设置线条颜色
颜色设置
通用颜色
其他颜色
浮点形式的RGB或者RGBA元组
十六进制的RGB或者RGBA字符串
1-2之间的小数作为的灰度值
X11/CSS4中规定的颜色名称
Xkcd中指定的颜色名称
Tableau调色板中的颜色
CN格式的颜色循环
b | 蓝色 |
g | 绿色 |
r | 红色 |
c | 蓝绿色 |
#FFFF00 | 黄色 |
m | 洋红色 |
y | 黄色 |
k | 黑色 |
w | 白色 |
0.5 | 灰度值字符串 |
标记设置
matplotlib.pyplot.plot的linestyle参数设置颜色设置线条样式
线条样式设置
1.实线'-'
2.双划线'--'
3.点划线'-.'
4.虚线':'
标记样式
marker参数,设置标记样式
. | 点标记 |
, | 像素标记 |
o | 实心圆标记 |
v | 倒三角标记 |
^ | 上三角标记 |
> | 右三角标记 |
< | 左三角标记 |
1 | 下花三角标记 |
2 | 上花三角标记 |
3 | 左花三角标记 |
4 | 右花三角标记 |
s | 实心正方形标记 |
p | 实心五角形标记 |
* | 星形标记 |
看看标记的用法
图布设置
设置画布
语法格式
matpoltlib.pyplot.figure(num=None,figsize=None,dpi=None,facecolor=None,edgecolor=None,frameon=True)
参数说明
1.num:图像编号或名称,数字为编号,字符串为名称,可以通过该参数激活不同的画布
2.figsize:指定画布的宽和高,单位为英寸
3.dpi:指定绘图对象的分辨率,即每英寸包含多少个像素,默认值为80。像素越大,画布越大
4.facecolor:背景颜色
5.edgeolor:边框颜色
6.frameon:是否显示边框,默认值为True,绘制边框,如果为False,则不绘制边框
这画布说白了就是背景。
设置坐标轴和网络格
设置坐标轴
设置坐标轴标题
xlabel函数设置x轴坐标轴标题,ylabel函数设置y轴坐标轴标题
解决中文乱码问题
plt.rcParame['font.sans-serif']=['SimHei']
设置坐标轴刻度
xticks函数设置x轴刻度,yticks函数设置y轴刻度
设置坐标轴范围
xlim函数设置x轴坐标轴范围,ylim函数设置y轴坐标轴范围
设置网络线
grid()函数设置网格线
文本标签_ 标题_图例
添加文本标签
matplotlib.pyplot.text(x,y,s,**kwargs)
fontsize | 字体大小 |
ha | 水平对齐方式 |
va | 垂直对齐方式 |
设置标题和图例
matplotlib.pyplot.title()
matplotlib.pyplot.legend()
best | 自适应 |
lower right | 右下方 |
center left | 左中间 |
center | 正中央 |
upper right | 右上方 |
lower left | 左下方 |
center right | 右中间 |
lower center | 下中间 |
upper left | 左上方 |
right | 右侧 |
upper center | 上中间 |
文本注释与坐标轴刻度线
添加注释
matplotlib.pyplot.annotate(s,xy,xytext,xycoords,arrowprops)
调整图表与画布边缘间距
matplotlib.pyplot.subplots_adjust(left,right,top,bottom)
坐标轴的刻度线
matplotlib.pyplot.tick_params(bottom,left,right,top)
matplotlib.pyplot.rcParams('xtick.direction')='in'
matplotlib.pyplot.rcParams('ytick.direction')='in'
边栏推荐
- Zhao Fuquan: to ensure supply in the short term, we should build a safe, efficient and resilient supply chain in the long term
- Airserver latest win64 bit personal screen projection software
- [MySQL] index classification
- Detailed explanation of twenty common software testing methods (the most complete in History)
- Business visualization - make your flowchart'run'up
- plain framework的实际应用和扩展
- Advanced skills of testers: a guide to the application of unit test reports
- Redis~02 缓存:更新数据时如何保证MySQL和Redis中的数据一致性?
- [micro service sentinel] @sentinelresource details
- Armbain系统根分区空间不足处理
猜你喜欢
STM32F030F4驱动TIM1637数码管芯片
window安装wsl(二)
MySQL -- index of InnoDB storage engine
数字化转型道阻且长,如何迈好关键的第一步
MySQL -- index of MyISAM storage engine
[机缘参悟-35]:鬼谷子-飞箝篇-远程连接、远程控制与远程测试之术
赵福全:短期解决保供,长期要打造安全、高效有韧性的供应链
有些能力,是工作中学不来的,看看这篇超过90%同行
shell 流程控制
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received
随机推荐
openresty 负载均衡
Programming English vocabulary notebook
flutter Unable to load asset: assets/images/888. png
Map container
有些能力,是工作中学不来的,看看这篇超过90%同行
What are the benefits of third party acceptance testing? Recommended by professional third-party software testing institutions
什么是马赛克?
Glass mosaic
[JUC learning road day 9] barrier derivatives
关于游戏性能优化的一些感想
Business visualization - make your flowchart'run'up
shell 流程控制
Zhao Fuquan: to ensure supply in the short term, we should build a safe, efficient and resilient supply chain in the long term
CADD course learning (3) -- target drug interaction
想请教股票开户要认识谁?在线开户是安全么?
Use 3DMAX to make a chess piece
Typescript enumeration
What is mosaic?
window10安装wsl(一)(WslRegisterDistribution ERROR)
Which securities company is better and which is safer to open a securities account