当前位置:网站首页>matplotlib 笔记: contourf & contour
matplotlib 笔记: contourf & contour
2022-06-30 10:03:00 【UQI-LIUWJ】
contour 和 contourf 分别绘制等高线和填充等高线
1 基本使用方法
matplotlib.pyplot.contourf([X, Y,] Z, [levels], **kwargs)2 主要参数
| X, Y | Z 中的值的坐标。 X 和 Y 必须都是二维的,具有与 Z 相同的形状(例如,通过 numpy.meshgrid 创建),或者它们必须都是一维的,这样 len(X) == N ,len(Y ) == M 是 Z 中的行数和列数。 X 和 Y 都必须单调排序。 |
| z | 绘制等高线的高度值。 |
| levels | 确定等高线/区域的数量和位置。 如果是整数n,请使用 MaxNLocator,它会尝试在 vmin 和 vmax 之间自动选择不超过 n+1 个”好“的等高级别。 如果是数组,则在指定级别绘制等高线。 这些值必须按升序排列。 |
| colors | 级别的颜色,即等高线轮廓的线条和等高线轮廓的区域。 该序列按升序循环用于各个级别。 如果序列比级别数短,则重复。 作为一种快捷方式,可以使用单一颜色字符串代替单元素列表,即“red”而不是 [“red”] 以用相同的颜色为所有级别着色。 默认情况下(值 None),将使用 cmap 指定的颜色图。 |
| cmap | ![]() |
| alpha | 透明度,0~1之间的数 |
| extend | 确定级别范围之外的值的轮廓着色。 如果“both”,则级别范围之外的值不着色。 如果是“min”、“max”或“both”,则为低于、高于或低于和高于水平范围的值着色。 低于 min(levels) 和高于 max(levels) 的值被映射到颜色图的低于/高于值。 |
3 举例
3.0 数据部分
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 最基本
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')
边栏推荐
- Koreano essential creates a professional style
- Questions about cookies and sessions
- Jinbei LT6 is powerful in the year of the tiger, making waves
- WGet -- 404 not found due to spaces in URL
- Notes on numerical calculation - iterative solution of linear equations
- 05_Node js 文件管理模块 fs
- 历史上的今天:微软收购 PowerPoint 开发商;SGI 和 MIPS 合并
- go-zero微服务实战系列(八、如何处理每秒上万次的下单请求)
- 转卡通学习笔记
- Skill combing [email protected] intelligent instrument teaching aids based on 51 series single chip microcomputer
猜你喜欢

移植完整版RT-Thread到GD32F4XX(详细)

苹果5G芯片被曝研发失败,QQ密码bug引热议,蔚来回应做空传闻,今日更多大新闻在此...

历史上的今天:微软收购 PowerPoint 开发商;SGI 和 MIPS 合并

记一次实习的经历,趟坑必备(一)

腾讯云数据库工程师能力认证重磅推出,各界共话人才培养难题

CVPR 2022 | Tsinghua & bytek & JD put forward BRT: Bridging Transformer for vision and point cloud 3D target detection

再测云原生数据库性能:PolarDB依旧最强,TDSQL-C、GaussDB变化不大

Arm新CPU性能提升22%,最高可组合12核,GPU首配硬件光追,网友:跟苹果的差距越来越大了...

Use keil5 software to simulate and debug gd32f305 from 0

MySQL log management, backup and recovery of databases (2)
随机推荐
CVPR 2022 | Tsinghua & bytek & JD put forward BRT: Bridging Transformer for vision and point cloud 3D target detection
The performance of arm's new CPU has been improved by 22%, up to 12 cores can be combined, and the GPU is first equipped with hardware optical tracking. Netizen: the gap with apple is growing
Go -- standard library sort package
Oracle creates a stored procedure successfully, but the compilation fails
Turn to cartoon learning notes
Deployment of efficient and versatile clusters lvs+kept highly available clusters
TypeScript–es5中的类,继承,静态方法
MySQL log management, backup and recovery of databases (2)
程序员需知的 59 个网站
Gd32 RT thread PWM drive function
Yixian e-commerce released its first quarterly report: adhere to R & D and brand investment to achieve sustainable and high-quality development
Robotframework learning notes: environment installation and robotframework browser plug-in installation
Koreano essential creates a professional style
Agile Development: super easy to use bucket estimation system
CSDN daily one practice 2021.11.06 question 1 (C language)
断路器HystrixCircuitBreaker
如何解决跨域
逸仙電商發布一季報:堅持研發及品牌投入,實現可持續高質量發展
那个程序员,被打了。
Enter the world of helium (hNT) hotspot servers to bring you different benefits




