当前位置:网站首页>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'边栏推荐
- [JUC learning road day 8] condition
- 众昂矿业:发展以氟化工为主的特色化工产业具有先天优势
- [MySQL] index creation, viewing and deletion
- Istio、eBPF 和 RSocket Broker:深入研究服务网格
- Openresty load balancing
- 91. (cesium chapter) cesium rocket launch simulation
- RPA: Bank digitalization, business process automation "a small step", and loan review efficiency "a big step"
- Advanced skills of testers: a guide to the application of unit test reports
- Unable to climb hill sort, directly insert sort
- Zhao Fuquan: to ensure supply in the short term, we should build a safe, efficient and resilient supply chain in the long term
猜你喜欢

Tcpdump command usage details

CKS CKA ckad change terminal to remote desktop

使用3DMax制作一个象棋棋子

赵福全:短期解决保供,长期要打造安全、高效有韧性的供应链

What is mosaic?

Aaai22 | structural tagging and interaction modeling: a "slim" network for graph classification
![Jielizhi Bluetooth headset quality control and production skills [chapter]](/img/ad/28e7461f8c5dc5c54a3f4da0c111ac.png)
Jielizhi Bluetooth headset quality control and production skills [chapter]

Introduction and use of plantuml

有些能力,是工作中学不来的,看看这篇超过90%同行

日本购物网站的网络乞丐功能
随机推荐
win 10 mstsc连接 RemoteApp
玻璃马赛克
Advanced skills of testers: a guide to the application of unit test reports
用JpaTransactionManager操作数据库事务
vim给目录加颜色
CKS CKA ckad change terminal to remote desktop
软件测试之「 性能测试」总结,新手上路必会知识点
Explain ThreadLocal in detail
数字化转型道阻且长,如何迈好关键的第一步
【微服务|Sentinel】sentinel整合openfeign
Airserver latest win64 bit personal screen projection software
众昂矿业:发展以氟化工为主的特色化工产业具有先天优势
通过Go语言创建CA与签发证书
CADD course learning (3) -- target drug interaction
若干互联网暴露面的收敛及处置建议
OpenVINO 模型性能评估工具—DL Workbench
What are the benefits of third party acceptance testing? Recommended by professional third-party software testing institutions
SWT/ANR问题--SWT 导致 kernel fuse deadlock
Huisheng Huiying 2022 intelligent, fast and simple video editing software
Cisco test -- the concept and configuration test of routing