当前位置:网站首页>(perfect solution) how to set the position of Matplotlib legend freely
(perfect solution) how to set the position of Matplotlib legend freely
2022-07-03 05:09:00 【Interval】
List of articles
Preface
plt.legend()
We know , This code will help us display the legend , And usually , It will be placed in a good position in the picture . But if our data , It takes up the whole image , here , There will be a problem with its position .
So how can we freely set the legend position ?
loc
This parameter has some built-in positions , If these positions are exactly what you want , Then use this , Very convenient .

plt.legend(loc=1)# This is equivalent to placing the legend in the upper right corner .
bbox_to_anchor
This is a unique skill , Because it can control any position .
plt.legend(bbox_to_anchor=(1,0))
This thing is a coordinate , The origin is the lower left corner of the graph . however , The numerical value of this coordinate represents the scale . such as
(1,0)# The lower right corner
(0,1)# top left corner
(0.5,0.5)# middle
(0.4,0.4)# A little lower left in the middle , ha-ha .
So , It's easy , Just slowly adjust yourself to the position you want . Be careful , It also supports negative numbers .

Final , Successfully adjusted to a middle , Left position haha .
Never forget the digger when drawing water , Learn from https://www.freesion.com/article/239347665/
边栏推荐
- 1111 online map (30 points)
- [set theory] relationship properties (symmetry | symmetry examples | symmetry related theorems | antisymmetry | antisymmetry examples | antisymmetry theorems)
- Redis 入门和数据类型讲解
- [backtrader source code analysis 5] rewrite several time number conversion functions in utils with Python
- Redis 击穿穿透雪崩
- Silent authorization login and registration of wechat applet
- Online VR model display - 3D visual display solution
- Redis 入門和數據類型講解
- Webapidom get page elements
- Automatic voltage rise and fall 5-40v multi string super capacitor charging chip and solution
猜你喜欢

The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article

(subplots用法)matplotlib如何绘制多个子图(轴域)

Coordinatorlayout appbarrayout recyclerview item exposure buried point misalignment analysis
![[Yu Yue education] basic reference materials of interchangeability and measurement technology of Zhongyuan Institute of Technology](/img/f1/d0dc4dc3fe49a2d2cd9e452a0ce31e.jpg)
[Yu Yue education] basic reference materials of interchangeability and measurement technology of Zhongyuan Institute of Technology

Actual combat 8051 drives 8-bit nixie tube

Review the configuration of vscode to develop golang

【实战项目】自主web服务器
![[set theory] relation properties (transitivity | transitivity examples | transitivity related theorems)](/img/c2/87358af6b2b2892a6eceb751b3b60c.jpg)
[set theory] relation properties (transitivity | transitivity examples | transitivity related theorems)

Ueditor, FCKeditor, kindeditor editor vulnerability

JQ style, element operation, effect, filtering method and transformation, event object
随机推荐
1115 counting nodes in a BST (30 points)
Notes | numpy-07 Slice and index
[basic grammar] Snake game written in C language
Ueditor, FCKeditor, kindeditor editor vulnerability
Do you know UVs in modeling?
Oracle SQL table data loss
Use Sqlalchemy module to obtain the table name and field name of the existing table in the database
(完美解决)matplotlib图例(legend)如何自由设置其位置
How to connect the network: Chapter 1 CSDN creation punch in
C language program ideas and several commonly used filters
Prepare for 2022 and welcome the "golden three silver four". The "summary of Android intermediate and advanced interview questions in 2022" is fresh, so that your big factory interview can go smoothly
appium1.22.x 版本后的 appium inspector 需单独安装
2022-02-11 daily clock in: problem fine brush
Audio Focus Series: write a demo to understand audio focus and audiomananger
2022-02-12 daily clock in: problem fine brush
Cross platform plug-in flutter for displaying local notifications_ local_ notifications
The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article
Thesis reading_ Chinese NLP_ ELECTRA
1094 the largest generation (25 points)
【批处理DOS-CMD命令-汇总和小结】-CMD窗口的设置与操作命令-关闭cmd窗口、退出cmd环境(exit、exit /b、goto :eof)