当前位置:网站首页>(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/
边栏推荐
- [research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached
- The 19th Zhejiang I. barbecue
- JQ style, element operation, effect, filtering method and transformation, event object
- Go language interface learning notes Continued
- 1103 integer factorization (30 points)
- Realize file download through the tag of < a > and customize the file name
- The consumption of Internet of things users is only 76 cents, and the price has become the biggest obstacle to the promotion of 5g industrial interconnection
- Pan details of deep learning
- 1106 lowest price in supply chain (25 points)
- 微服务常见面试题
猜你喜欢
[set theory] relation properties (transitivity | transitivity examples | transitivity related theorems)
Overview of basic knowledge of C language
[research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached
Celebrate the new year together
Coordinatorlayout appbarrayout recyclerview item exposure buried point misalignment analysis
[basic grammar] C language uses for loop to print Pentagram
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)
Detailed explanation of yolov5 training own data set
JDBC database operation
JQ style, element operation, effect, filtering method and transformation, event object
随机推荐
Notes | numpy-07 Slice and index
[research materials] 2021 China's game industry brand report - Download attached
Burp suite plug-in based on actual combat uses tips
Huawei personally ended up developing 5g RF chips, breaking the monopoly of Japan and the United States
【实战项目】自主web服务器
Compile and decompile GCC common instructions
Maximum continuous sub segment sum (dynamic programming, recursive, recursive)
1118 birds in forest (25 points)
Interface frequency limit access
[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)
My first Smartphone
乾元通多卡聚合路由器的技术解析
The consumption of Internet of things users is only 76 cents, and the price has become the biggest obstacle to the promotion of 5g industrial interconnection
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)
BTC-密码学原理
Realize file download through the tag of < a > and customize the file name
Redis 入門和數據類型講解
Mobile terminal - uniapp development record (public request encapsulation)
Notes | numpy-11 Array operation
[backtrader source code analysis 4] use Python to rewrite the first function of backtrader: time2num, which improves the efficiency by 2.2 times