FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib.github.com/examples/misc/contour_manual.py at master · cartosat/matplotlib.github.com · GitHub
cartosat
matplotlib.github.com
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib.github.com
/
examples
/
misc
/
contour_manual.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (37 loc) · 1.64 KB
Breadcrumbs
matplotlib.github.com
/
examples
/
misc
/
contour_manual.py
Copy path
File metadata and controls
49 lines (37 loc) · 1.64 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
Example of displaying your own contour lines and polygons using ContourSet.
"""
import
matplotlib
.
pyplot
as
plt
from
matplotlib
.
contour
import
ContourSet
import
matplotlib
.
cm
as
cm
# Contour lines for each level are a list/tuple of polygons.
lines0
=
[[[
0
,
0
], [
0
,
4
]]]
lines1
=
[[[
2
,
0
], [
1
,
2
], [
1
,
3
]]]
lines2
=
[[[
3
,
0
], [
3
,
2
]], [[
3
,
3
], [
3
,
4
]]]
# Note two lines.
# Filled contours between two levels are also a list/tuple of polygons.
# Points can be ordered clockwise or anticlockwise.
filled01
=
[[[
0
,
0
], [
0
,
4
], [
1
,
3
], [
1
,
2
], [
2
,
0
]]]
filled12
=
[[[
2
,
0
], [
3
,
0
], [
3
,
2
], [
1
,
3
], [
1
,
2
]],
# Note two polygons.
[[
1
,
4
], [
3
,
4
], [
3
,
3
]]]
plt
.
figure
()
# Filled contours using filled=True.
cs
=
ContourSet
(
plt
.
gca
(), [
0
,
1
,
2
], [
filled01
,
filled12
],
filled
=
True
,
cmap
=
cm
.
bone
)
cbar
=
plt
.
colorbar
(
cs
)
# Contour lines (non-filled).
lines
=
ContourSet
(
plt
.
gca
(), [
0
,
1
,
2
], [
lines0
,
lines1
,
lines2
],
cmap
=
cm
.
cool
,
linewidths
=
3
)
cbar
.
add_lines
(
lines
)
plt
.
axis
([
-
0.5
,
3.5
,
-
0.5
,
4.5
])
plt
.
title
(
'User-specified contours'
)
# Multiple filled contour lines can be specified in a single list of polygon
# vertices along with a list of vertex kinds (code types) as described in the
# Path class. This is particularly useful for polygons with holes.
# Here a code type of 1 is a MOVETO, and 2 is a LINETO.
plt
.
figure
()
filled01
=
[[[
0
,
0
], [
3
,
0
], [
3
,
3
], [
0
,
3
], [
1
,
1
], [
1
,
2
], [
2
,
2
], [
2
,
1
]]]
kinds01
=
[[
1
,
2
,
2
,
2
,
1
,
2
,
2
,
2
]]
cs
=
ContourSet
(
plt
.
gca
(), [
0
,
1
], [
filled01
], [
kinds01
],
filled
=
True
)
cbar
=
plt
.
colorbar
(
cs
)
plt
.
axis
([
-
0.5
,
3.5
,
-
0.5
,
3.5
])
plt
.
title
(
'User specified filled contours with holes'
)
plt
.
show
()
Back
|
FazBrowse Home
|
New Git URL