当前位置:网站首页>(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)
- Bluebridge cup real topic 2020 palindrome date simulation construction provincial competition
- Three representations of signed numbers: original code, inverse code and complement code
- Retirement plan fails, 64 year old programmer starts work again
- Gbase8s unique index and non unique index
- Do you know UVs in modeling?
- BTC-密码学原理
- XML配置文件
- Wechat applet waterfall flow and pull up to the bottom
- BIO、NIO、AIO区别
猜你喜欢
![[clock 223] [binary tree] [leetcode high frequency]: 102 Sequence traversal of binary tree](/img/0f/bc8c44aee7a2c9dccac050b1060017.jpg)
[clock 223] [binary tree] [leetcode high frequency]: 102 Sequence traversal of binary tree

Coordinatorlayout appbarrayout recyclerview item exposure buried point misalignment analysis

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

Yolov5 model construction source code details | CSDN creation punch in

Mobile terminal - uniapp development record (public request encapsulation)

leetcode435. Non overlapping interval

es7创建索引容易犯的错误
![[research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached](/img/95/833f5ec20207ee5d7e6cdfa7208c5e.jpg)
[research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached

"Hands on deep learning" pytorch edition Chapter II exercise

Online VR model display - 3D visual display solution
随机推荐
Redis 击穿穿透雪崩
Bluebridge cup real topic 2020 palindrome date simulation construction provincial competition
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
M1 Pro install redis
Webapidom get page elements
Analysis of proxy usage of ES6 new feature
Audio Focus Series: write a demo to understand audio focus and audiomananger
leetcode860. Lemonade change
Compile and decompile GCC common instructions
Notes | numpy-07 Slice and index
Yolov5 input (II) | CSDN creative punch in
1115 counting nodes in a BST (30 points)
Do you know UVs in modeling?
Retirement plan fails, 64 year old programmer starts work again
Kept hot standby and haproxy
[backtrader source code analysis 5] rewrite several time number conversion functions in utils with Python
Redis 入门和数据类型讲解
JS dynamic table creation
1119 pre- and post order traversals (30 points)
Flutter monitors volume to realize waveform visualization of audio