当前位置:网站首页>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'边栏推荐
- 2022安全员-C证考试题模拟考试题库及模拟考试
- 若干互联网暴露面的收敛及处置建议
- Istio、eBPF 和 RSocket Broker:深入研究服务网格
- 2022 examination questions and online simulation examination for safety management personnel of hazardous chemical business units
- 力扣 710. 黑名单中的随机数
- Convergence and disposal suggestions of some Internet exposure surfaces
- Wechat personal small store one click opening assistant applet development
- [JUC learning road day 8] condition
- Explain the volatile keyword
- CKS CKA CKAD 将终端更改为远程桌面
猜你喜欢

window10安装wsl(一)(WslRegisterDistribution ERROR)

微信个人小商店一键开通助手小程序开发

Cisco exam -- redundant network

Cisco test -- the concept and configuration test of routing

The online beggar function of Japanese shopping websites

flutter Unable to load asset: assets/images/888.png

Huisheng Huiying 2022 intelligent, fast and simple video editing software

玻璃马赛克

软件测试之「 性能测试」总结,新手上路必会知识点

Unable to climb hill sort, directly insert sort
随机推荐
Cisco exam -- redundant network
Jielizhi, production line assembly link [chapter]
tcpdump命令使用详解
[MySQL] basic use of explain and the function of each column
Aaai22 | structural tagging and interaction modeling: a "slim" network for graph classification
The digital summit is popular, and city chain technology has triggered a new round of business transformation
CKS CKA CKAD 将终端更改为远程桌面
【微服务|Sentinel】SentinelResourceAspect详解
Happy number [fast and slow pointer of ring PROBLEMS]
[JUC learning road day 8] condition
Cisco -- highly available and reliable network examination
数字峰会人气火爆,城链科技引发新一轮商业变革
【小程序】通过scroll-view组件实现左右【滑动】列表
js——arguments的使用
Use of locust
Mysql 5.7 实现 rank 排名
What is mosaic?
“35岁,公司老总,月薪2万送外卖“:时代抛弃你,连声再见都没有
shell 自定义函数
Business visualization - make your flowchart'run'up