当前位置:网站首页>(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/
边栏推荐
- Notes | numpy-11 Array operation
- Without 50W bride price, my girlfriend was forcibly dragged away. What should I do
- Objects. Requirenonnull method description
- SSM framework integration
- study hard and make progress every day
- Online VR model display - 3D visual display solution
- Cross platform plug-in flutter for displaying local notifications_ local_ notifications
- 2022-02-11 daily clock in: problem fine brush
- Go language interface learning notes
- 50 practical applications of R language (36) - data visualization from basic to advanced
猜你喜欢

M1 Pro install redis
![[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

(完美解决)matplotlib图例(legend)如何自由设置其位置

Automatic voltage rise and fall 5-40v multi string super capacitor charging chip and solution

Thesis reading_ Chinese medical model_ eHealth

Audio Focus Series: write a demo to understand audio focus and audiomananger

Web APIs exclusivity
![[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)](/img/2a/362f3b0491f721d89336d4f468c9dd.jpg)
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)

Kept hot standby and haproxy

Burp suite plug-in based on actual combat uses tips
随机推荐
50 practical applications of R language (36) - data visualization from basic to advanced
1107 social clusters (30 points)
ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)
On typescript and grammar
Chapter II program design of circular structure
Shuttle + alluxio accelerated memory shuffle take-off
Shuttle + Alluxio 加速内存Shuffle起飞
Notes | numpy-10 Iterative array
Redis 入門和數據類型講解
Thesis reading_ Chinese medical model_ eHealth
Compile and decompile GCC common instructions
[research materials] the fourth quarter report of the survey of Chinese small and micro entrepreneurs in 2021 - Download attached
1095 cars on campus (30 points)
Keepalived热备与HAProxy
Yolov5 input (II) | CSDN creative punch in
How to connect the network: Chapter 2 (Part 1): a life cycle of TCP connection | CSDN creation punch in
Three representations of signed numbers: original code, inverse code and complement code
[set theory] relationship properties (common relationship properties | relationship properties examples | relationship operation properties)
Problems encountered in fuzzy query of SQL statements
leetcode452. Detonate the balloon with the minimum number of arrows