当前位置:网站首页>(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/
边栏推荐
- Thesis reading_ Tsinghua Ernie
- 2022-02-12 daily clock in: problem fine brush
- Chapter II program design of circular structure
- Cross platform plug-in flutter for displaying local notifications_ local_ notifications
- Go language interface learning notes
- Introduction to deep learning (II) -- univariate linear regression
- Maximum continuous sub segment sum (dynamic programming, recursive, recursive)
- Notes | numpy-08 Advanced index
- 1099 build a binary search tree (30 points)
- appium1.22. Appium inspector after X version needs to be installed separately
猜你喜欢

Keepalived热备与HAProxy

Gbase8s unique index and non unique index

Analysis of proxy usage of ES6 new feature

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

How to connect the network: Chapter 2 (Part 1): a life cycle of TCP connection | CSDN creation punch in

On typescript and grammar
![[set theory] relationship properties (common relationship properties | relationship properties examples | relationship operation properties)](/img/af/8dfa783c87363a9d75c52e7680d508.jpg)
[set theory] relationship properties (common relationship properties | relationship properties examples | relationship operation properties)

Web APIs exclusivity

Gbase8s composite index (I)

JS dynamic table creation
随机推荐
[research materials] 2022q1 game preferred casual game distribution circular - Download attached
Redis 过期淘汰机制
The current market situation and development prospect of the global gluten tolerance test kit industry in 2022
SSM framework integration
Detailed explanation of the output end (head) of yolov5 | CSDN creation punch in
Notes | numpy-11 Array operation
[basic grammar] C language uses for loop to print Pentagram
Notes | numpy-10 Iterative array
Dynamic programming - related concepts, (tower problem)
Redis 入门和数据类型讲解
Flutter monitors volume to realize waveform visualization of audio
What is UUID
Introduction to deep learning (II) -- univariate linear regression
leetcode452. Detonate the balloon with the minimum number of arrows
1095 cars on campus (30 points)
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)
Cross platform plug-in flutter for displaying local notifications_ local_ notifications
ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)
Objects. Requirenonnull method description
Automatic voltage rise and fall 5-40v multi string super capacitor charging chip and solution