当前位置:网站首页>Matplotlib常用設置
Matplotlib常用設置
2022-07-01 23:17: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'边栏推荐
- 内存泄露和内存溢出的区别是什么?
- 【嵌入式系统课设】单个按键控制LED灯
- 2022安全员-C证考试题模拟考试题库及模拟考试
- Groups and ranges of regular series
- Simple interactive operation of electron learning (III)
- window10安装wsl(一)(WslRegisterDistribution ERROR)
- 硅谷产品实战学习感触
- 2022 safety officer-c certificate examination question simulation examination question bank and simulation examination
- 每日三题 6.28
- CADD课程学习(3)-- 靶点药物相互作用
猜你喜欢

CKS CKA ckad change terminal to remote desktop

数字化转型道阻且长,如何迈好关键的第一步

Unable to climb hill sort, directly insert sort

You probably haven't noticed the very important testing strategy in your work

2022年R1快开门式压力容器操作考题及答案

Huisheng Huiying 2022 intelligent, fast and simple video editing software

plain framework的实际应用和扩展

工作中非常重要的测试策略,你大概没注意过吧

What is mosaic?

"35 years old, the boss of the company, with a monthly salary of 20000, give away takeout": the times abandoned you, not even saying goodbye
随机推荐
Practical application and extension of plain framework
会声会影2022智能、快速、简单的视频剪辑软件
[JUC learning road day 9] barrier derivatives
什么是马赛克?
通过Go语言创建CA与签发证书
You probably haven't noticed the very important testing strategy in your work
Understanding threads
rviz打开后如何显示实时2D地图
玻璃马赛克
STM32F030F4驱动TIM1637数码管芯片
Jerry's burning of upper version materials requires [chapter]
Summary of "performance testing" of software testing, novice will know the knowledge points on the road
[MySQL] index creation, viewing and deletion
关于游戏性能优化的一些感想
【微服务|Sentinel】SentinelResourceAspect详解
[micro service sentinel] sentinelresourceaspect details
每日三题 6.30
Some thoughts on game performance optimization
Yoga27 multidimensional all-in-one computer with excellent appearance and high-end configuration
Jerry's records are powered by Vbat with a power supply voltage of 4.2V [chapter]