網站首頁 編程語言 正文
以下面代碼為例
import matplotlib.pyplot as plt
from pylab import mpl
mpl.rcParams['font.sans-serif'] = ['SimHei'] # 用來顯示中文,不然會亂碼
x = range(4)
y = [120, 200, 250, 600]
plt.bar(x=x, height=y, color='r', width=0.5, edgecolor='g', lw=2)
plt.title('電子產品出售表')
plt.xticks(x, ['電腦', '手機', '筆記本', '耳機'])
plt.yticks(range(0, 1000, 100))
plt.legend(["商品名/銷售額"], loc='upper center')
plt.show()
?
loc 參數
用來調整圖例的位置,如上圖讓圖例的位置處于上邊的中心處,共有十個可選參數,全部去試一遍吧。
['upper left', 'upper center', 'upper right',
'center left', 'center', 'center right',
'best', 'right',
'lower left', 'lower center', 'lower right']
?
fontsize 參數
調整圖例里的字體大小,可選參數有七種。
['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large']
?
frameon,facecolor,edgecolor 參數
分別為是否設置圖例邊框(默認為True),設置背景顏色,設置邊框顏色(無邊框時無效),例:
plt.legend(["商品名/銷售額"], loc='upper center', facecolor='red', edgecolor='blue')
?
title 參數
設置圖例標題哦,例:
plt.legend(["商品名/銷售額"], loc='upper center', title='社會公司')
原文鏈接:https://blog.csdn.net/Mr_blueD/article/details/88210961
相關推薦
- 2022-10-02 C++?OpenCV實戰之手寫數字識別_C 語言
- 2023-01-14 詳解Go語言如何進行Http調用_Golang
- 2022-11-21 C++?getcwd函數獲取項目運行路徑方法詳解_C 語言
- 2022-10-29 subplots_adjust()函數--matplotlib
- 2022-06-15 python?OpenCV?圖像通道數判斷_python
- 2022-09-10 詳解Python腳本如何設置試用期_python
- 2022-03-30 Android中圖片占用內存的深入分析_Android
- 2022-06-02 C#生成帶注釋的dll并引用實現_C#教程
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支