当前位置:网站首页>Matplotlib notes: contour & Contour
Matplotlib notes: contour & Contour
2022-06-30 10:43:00 【UQI-LIUWJ】
contour and contourf Draw contour lines and fill contour lines respectively
1 Basic usage
matplotlib.pyplot.contourf([X, Y,] Z, [levels], **kwargs)
2 main parameter
X, Y | Z Coordinates of values in . X and Y Must be two-dimensional , Have and Z The same shape ( for example , adopt numpy.meshgrid establish ), Or they must all be one-dimensional , such len(X) == N ,len(Y ) == M yes Z The number of rows and columns in . X and Y Must be sorted monotonically . |
z | Draw the height value of the contour line . |
levels | Determine contour lines / Number and location of areas . If it's an integer n, Please use MaxNLocator, It will try to vmin and vmax No more than... Are automatically selected between n+1 individual ” good “ At the same high level . If it's an array , Contour lines are drawn at the specified level . These values must be arranged in ascending order . |
colors | Color of level , That is, contour lines and contour areas . This sequence loops through the levels in ascending order . If the sequence is shorter than the number of levels , Then repeat . As a shortcut , You can use a single color string instead of a single element list , namely “red” instead of [“red”] Color all levels with the same color . By default ( value None), Will use cmap Specified color map . |
cmap | ![]() |
alpha | transparency ,0~1 Number between |
extend | Determines the outline shading of values outside the level range . If “both”, Values outside the level range are not shaded . If it is “min”、“max” or “both”, Is less than 、 Values above or below and above the horizontal range are shaded . lower than min(levels) And above max(levels) The value of is mapped to the lower than of the color map / Above value . |
3 give an example
3.0 Data section
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(1, 10)
y = x.reshape(-1, 1)
h = x * y
print(x,'\n',y,'\n',h)
'''
[1 2 3 4 5 6 7 8 9]
[[1]
[2]
[3]
[4]
[5]
[6]
[7]
[8]
[9]]
[[ 1 2 3 4 5 6 7 8 9]
[ 2 4 6 8 10 12 14 16 18]
[ 3 6 9 12 15 18 21 24 27]
[ 4 8 12 16 20 24 28 32 36]
[ 5 10 15 20 25 30 35 40 45]
[ 6 12 18 24 30 36 42 48 54]
[ 7 14 21 28 35 42 49 56 63]
[ 8 16 24 32 40 48 56 64 72]
[ 9 18 27 36 45 54 63 72 81]]
'''
3.1 The most basic
plt.contourf(x.reshape(-1),
y.reshape(-1),
h)
3.2 level
plt.contourf(x.reshape(-1), y.reshape(-1), h, levels=1)
plt.contourf(x.reshape(-1), y.reshape(-1), h, levels=[1,3,15,35])
3.3 extend
plt.contourf(x.reshape(-1), y.reshape(-1), h, levels=[13,15,35], )
plt.contourf(x.reshape(-1), y.reshape(-1), h, levels=[13,15,35], extend='both')
边栏推荐
- Viewing technological changes through Huawei Corps (V): smart Park
- R language plot visualization: use plot to visualize the prediction confidence of the multi classification model, the prediction confidence of each data point of the model in the 2D grid, and the conf
- Ionic4 drag the ion reorder group component to change the item order
- 移植完整版RT-Thread到GD32F4XX(详细)
- ArcGIS Pro脚本工具(5)——排序后删除重复项
- Dyson design award, changing the world with sustainable design
- ionic4 ion-reorder-group组件拖拽改变item顺序
- 苹果高管公然“开怼”:三星抄袭 iPhone,只加了个大屏
- 逸仙電商發布一季報:堅持研發及品牌投入,實現可持續高質量發展
- June training (day 30) - topology sorting
猜你喜欢
CVPR 2022 | Tsinghua & bytek & JD put forward BRT: Bridging Transformer for vision and point cloud 3D target detection
Use keil5 software to simulate and debug gd32f305 from 0
今晚19:00知识赋能第2期直播丨OpenHarmony智能家居项目之控制面板界面设计
The latest SCI impact factor release: the highest score of domestic journals is 46! Netizen: I understand if
Koreano essential creates a professional style
智能DNA分子纳米机器人模型来了
Dow Jones Industrial Average
Kernel linked list (general linked list) "list.h" simple version and individual comments
逸仙電商發布一季報:堅持研發及品牌投入,實現可持續高質量發展
Apple's 5g chip was revealed to have failed in research and development, and the QQ password bug caused heated discussion. Wei Lai responded to the short selling rumors. Today, more big news is here
随机推荐
技能梳理[email protected]基于51系列单片机的智能仪器教具
mysql数据库基础:存储过程和函数
今晚19:00知识赋能第2期直播丨OpenHarmony智能家居项目之控制面板界面设计
How to seize the opportunity of NFT's "chaos"?
& and - > priority
SGD有多种改进的形式,为什么大多数论文中仍然用SGD?
The rising star of Goldshell STC box
Use keil5 software to simulate and debug gd32f305 from 0
"Kunming City coffee map" was opened again, and coffee brought the city closer
GeoffreyHinton:我的五十年深度学习生涯与研究心法
Skill combing [email protected] intelligent instrument teaching aids based on 51 series single chip microcomputer
Arm新CPU性能提升22%,最高可组合12核,GPU首配硬件光追,网友:跟苹果的差距越来越大了...
Ionic4 drag the ion reorder group component to change the item order
Koreano essential creates a professional style
Oracle creates a stored procedure successfully, but the compilation fails
移植完整版RT-Thread到GD32F4XX(详细)
Ant s19xp appeared in 140t, why is it called the computing power ceiling by the world
转卡通学习笔记
Overview of currency
R language plot visualization: use plot to visualize the prediction confidence of the multi classification model, the prediction confidence of each data point of the model in the 2D grid, and the conf