当前位置:网站首页>Solutions to common problems in visualization (IX) background color
Solutions to common problems in visualization (IX) background color
2022-04-23 10:54:00 【The big pig of the little pig family】
Background color problem
One . Preface
In the process of data visualization , We usually encounter the problem of changing the color of Beijing , Today, let's study together in matploltlib The color of one canvas in the changes .
Two . Solution
matplotlib A canvas is made up of a figure
and axes
form .
2.1 change figure Color
every last Figure
Objects all have one patch
attribute , Store his Beijing Rectangle
object , Get Association Rectangle
Use after object set_color()
Method to set the background color .
import matplotlib.pyplot as plt
figure, ax = plt.subplots(1, 1)
patch = figure.patch
patch.set_color("red")
plt.show()
Change effect :
2.2 change axes The background color
Empathy , every last Axes
Objects are also associated with a Rectangle
object , Use the same method to change the background color . The code is as follows :
import matplotlib.pyplot as plt
import numpy as np
figure, ax = plt.subplots(1, 1)
patch = ax.patch
patch.set_color("blue")
plt.show()
The effect is as follows :
2.3 Advanced - The background uses a gradient
The background color can not only use solid color, but also use gradient color , The principle that it implements is to use imshow
Method to draw a gradient background on the background , And modify his transparency , So you can draw on the gradient background . However, it should be noted that if the background transparency is too large, it will have a great impact on the actual drawing .
import matplotlib.pyplot as plt
import numpy as np
figure, ax = plt.subplots(1, 1)
patch = ax.patch
patch.set_color("blue")
x = np.arange(200)
y = np.arange(200)
_, yv = np.meshgrid(x, y)
im = ax.imshow(yv, interpolation='bicubic',cmap="PuOr",
vmin=0, vmax=200, alpha=0.5)
plt.plot([1, 100], [30, 150], color='k')
plt.show()
The effect is as follows :
3、 ... and . Reference resources
版权声明
本文为[The big pig of the little pig family]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230617063449.html
边栏推荐
- 解决方案架构师的小锦囊 - 架构图的 5 种类型
- 206. Reverse linked list (linked list)
- 454. Sum of four numbers (hash table)
- Esp32 learning - use and configuration of GPIO
- 707. Design linked list (linked list)
- Cve-2019-0708 vulnerability exploitation of secondary vocational network security 2022 national competition
- MapReduce core and foundation demo
- Differences among restful, soap, RPC, SOA and microservices
- MySQL how to merge the same data in the same table
- 一个微博数据库设计带来的简单思考
猜你喜欢
Solution architect's small bag - 5 types of architecture diagrams
Download and installation steps of xshell + xftp
Learning note 5 - gradient explosion and gradient disappearance (k-fold cross verification)
Charles 功能介绍和使用教程
JVM - common parameters
Swagger2 接口如何导入Postman
Source insight 4.0 FAQs
Reading integrity monitoring techniques for vision navigation systems - 5 Results
解决方案架构师的小锦囊 - 架构图的 5 种类型
《Neo4j权威指南》简介,求伯君、周鸿袆、胡晓峰、周涛等大咖隆重推荐
随机推荐
Read integrity monitoring techniques for vision navigation systems - 4 multiple faults in vision system
Define linked list (linked list)
最强日期正则表达式
解决方案架构师的小锦囊 - 架构图的 5 种类型
MySql常用语句
Wonderful review | deepnova x iceberg meetup online "building a real-time data Lake based on iceberg"
Contact between domain name and IP address
59. Spiral matrix (array)
Is the pointer symbol of C language close to variable type or variable name?
【leetcode】107. Sequence traversal of binary tree II
使用zerotier让异地设备组局域网
Cve-2019-0708 vulnerability exploitation of secondary vocational network security 2022 national competition
Manjaro installation and configuration (vscode, wechat, beautification, input method)
MapReduce core and foundation demo
Latex usage
LeetCode 1249. Minimum remove to make valid parents - FB high frequency question 1
/Can etc / shadow be cracked?
Reading integrity monitoring techniques for vision navigation systems - 5 Results
精彩回顾 | DEEPNOVA x Iceberg Meetup Online《基于Iceberg打造实时数据湖》
Dirichlet prefix sum (number theory optimization formula sub complexity weapon)