当前位置:网站首页>(完美解决)matplotlib图例(legend)如何自由设置其位置
(完美解决)matplotlib图例(legend)如何自由设置其位置
2022-07-03 05:07:00 【音程】
前言
plt.legend()
我们知道,这一条代码会帮我们显示图例,而且通常,其会放置在图片中一个不错的位置。但是如果我们的数据,占满了整个图像,此时,其放的位置就会出问题了。
那么我们该如何自由设置图例位置呢?
loc
这个参数内置了一些位置,如果这些位置恰好有你想要的,那么用这个就行了,很方便。
plt.legend(loc=1)#这个就等价于将图例放置在右上角的位置。
bbox_to_anchor
这个是绝招,因为其可以控制任意位置。
plt.legend(bbox_to_anchor=(1,0))
这个玩意是一个坐标,原点就是图的左下角。但是,这个坐标的数值表示的是比例。比如
(1,0)#右下角
(0,1)#左上角
(0.5,0.5)#中间
(0.4,0.4)#中间往左下一点,哈哈。
所以说,很简单了,你自己慢慢调到你想要的位置就行了。注意,上面还支持负数哦。
最终,成功调节到了一个中间,偏左的位置哈哈。
吃水不忘挖井人,学习自https://www.freesion.com/article/239347665/
边栏推荐
- 2022-02-11 daily clock in: problem fine brush
- JS dynamic table creation
- Huawei personally ended up developing 5g RF chips, breaking the monopoly of Japan and the United States
- How to connect the network: Chapter 1 CSDN creation punch in
- Market status and development prospect prediction of global fermentation acid industry in 2022
- Chapter II program design of circular structure
- Kept hot standby and haproxy
- Thesis reading_ ICD code_ MSMN
- Three representations of signed numbers: original code, inverse code and complement code
- 1087 all roads lead to Rome (30 points)
猜你喜欢
ZABBIX monitoring of lamp architecture (2): ZABBIX basic operation
leetcode452. Detonate the balloon with the minimum number of arrows
appium1.22.x 版本後的 appium inspector 需單獨安裝
[research materials] annual report of China's pension market in 2021 - Download attached
Mobile terminal - uniapp development record (public request encapsulation)
[set theory] relationship properties (symmetry | symmetry examples | symmetry related theorems | antisymmetry | antisymmetry examples | antisymmetry theorems)
Audio Focus Series: write a demo to understand audio focus and audiomananger
Handler understands the record
Celebrate the new year together
Analysis of proxy usage of ES6 new feature
随机推荐
Kept hot standby and haproxy
Three representations of signed numbers: original code, inverse code and complement code
Notes | numpy-07 Slice and index
appium1.22. Appium inspector after X version needs to be installed separately
First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT
leetcode860. Lemonade change
JS string and array methods
How to connect the network: Chapter 1 CSDN creation punch in
Current market situation and development prospect forecast of the global fire boots industry in 2022
Shell script Basics - basic grammar knowledge
1094 the largest generation (25 points)
Pan details of deep learning
1110 complete binary tree (25 points)
Burp suite plug-in based on actual combat uses tips
The process of browser accessing the website
Sprintf formatter abnormal exit problem
Go language interface learning notes
appium1.22.x 版本后的 appium inspector 需单独安装
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)
Use Sqlalchemy module to obtain the table name and field name of the existing table in the database