python - 同一轮廓的不同线条样式
问题描述
我有一个等高线图,对于固定值,有两个单独的等高线。我想将这两个轮廓彼此区分开来,例如一个带有虚线的轮廓和一个带有简单线条的轮廓。我正在使用 python 和 Matplotlib。
谢谢!
在下图中,我希望将红色轮廓之一(对应于值 1)用虚线表示。 在此处输入图像描述
解决方案
阅读 的文档contour()
,您会发现可以像使用颜色列表一样使用线型列表。
见这里。
linestyles{None, 'solid', 'dashed', 'dashdot', 'dotted'}, optional
Only applies to contour.
If linestyles is None, the default is 'solid' unless the lines are monochrome. In that case, negative contours will take their linestyle from rcParams["contour.negative_linestyle"] (default: 'dashed') setting.
linestyles can also be an iterable of the above strings specifying a set of linestyles to be used. If this iterable is shorter than the number of contour levels it will be repeated as necessary.
推荐阅读
- python - geojson 文件的 JSONDecodeError
- sqlalchemy - Flask SQLAlchemy - 使用非默认命名模式查询视图。最好的方法是什么?
- java - 在 Java 中的单元测试期间无法禁用 Spring Vault
- python - 从列表列表中获取所有组合(组合算法)
- python - 从 pandas 数据框中提取第一个和最后一个匹配的索引列表
- python - 使用最小化、差分演化和流域跳跃进行模型优化
- android - 增强每个循环的性能,每个循环都有一个内部循环
- javascript - 如何在 Draft.js 中停止插入符号闪烁?
- c++ - C++ Type Traits if_v(自动类型推断+确保相同类型)
- bash - 如何显示 HEAD 和 origin/master(或最新的共同祖先)之间的所有提交