当前位置:网站首页>(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/
边栏推荐
- sql语句模糊查询遇到的问题
- The 19th Zhejiang I. barbecue
- Based on RFC 3986 (unified resource descriptor (URI): general syntax)
- XML配置文件
- 1119 pre- and post order traversals (30 points)
- Introduction to deep learning - definition Introduction (I)
- Redis 入門和數據類型講解
- Actual combat 8051 drives 8-bit nixie tube
- 5-36v input automatic voltage rise and fall PD fast charging scheme drawing 30W low-cost chip
- "Hands on deep learning" pytorch edition Chapter II exercise
猜你喜欢

Ueditor, FCKeditor, kindeditor editor vulnerability

JQ style, element operation, effect, filtering method and transformation, event object

Use posture of sudo right raising vulnerability in actual combat (cve-2021-3156)
![[batch dos-cmd command - summary and summary] - CMD window setting and operation command - close CMD window and exit CMD environment (exit, exit /b, goto: EOF)](/img/ce/d6f4fb30727e7436b6443537429ad4.png)
[batch dos-cmd command - summary and summary] - CMD window setting and operation command - close CMD window and exit CMD environment (exit, exit /b, goto: EOF)

Shuttle + Alluxio 加速内存Shuffle起飞

Keepalived热备与HAProxy

【实战项目】自主web服务器

Shallow and first code

The programmer resigned and was sentenced to 10 months for deleting the code. JD came home and said that it took 30000 to restore the database. Netizen: This is really a revenge

Pan details of deep learning
随机推荐
Do you know UVs in modeling?
Class loading mechanism (detailed explanation of the whole process)
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
Use posture of sudo right raising vulnerability in actual combat (cve-2021-3156)
RT thread flow notes I startup, schedule, thread
Basic knowledge of reflection (detailed explanation)
Gbase8s unique index and non unique index
appium1.22.x 版本后的 appium inspector 需单独安装
1103 integer factorization (30 points)
How to connect the network: Chapter 2 (Part 1): a life cycle of TCP connection | CSDN creation punch in
JS scope
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)
Silent authorization login and registration of wechat applet
Gbase8s composite index (I)
Notes | numpy-07 Slice and index
Detailed explanation of the output end (head) of yolov5 | CSDN creation punch in
Pan details of deep learning
1094 the largest generation (25 points)
2022-02-11 daily clock in: problem fine brush
M1 Pro install redis