FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib/lib/matplotlib/tri/triplot.py at master · thomasgit/matplotlib · GitHub
thomasgit
matplotlib
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib
/
lib
/
matplotlib
/
tri
/
triplot.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
78 lines (59 loc) · 2.37 KB
Breadcrumbs
matplotlib
/
lib
/
matplotlib
/
tri
/
triplot.py
Copy path
File metadata and controls
78 lines (59 loc) · 2.37 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from
__future__
import
print_function
from
matplotlib
.
cbook
import
ls_mapper
from
matplotlib
.
patches
import
PathPatch
from
matplotlib
.
path
import
Path
from
matplotlib
.
tri
.
triangulation
import
Triangulation
import
numpy
as
np
def
triplot
(
ax
,
*
args
,
**
kwargs
):
"""
Draw a unstructured triangular grid as lines and/or markers to
the :class:`~matplotlib.axes.Axes`.
The triangulation to plot can be specified in one of two ways;
either::
triplot(triangulation, ...)
where triangulation is a :class:`~matplotlib.tri.Triangulation`
object, or
::
triplot(x, y, ...)
triplot(x, y, triangles, ...)
triplot(x, y, triangles=triangles, ...)
triplot(x, y, mask=mask, ...)
triplot(x, y, triangles, mask=mask, ...)
in which case a Triangulation object will be created. See
:class:`~matplotlib.tri.Triangulation` for a explanation of these
possibilities.
The remaining args and kwargs are the same as for
:meth:`~matplotlib.axes.Axes.plot`.
**Example:**
.. plot:: mpl_examples/pylab_examples/triplot_demo.py
"""
import
matplotlib
.
axes
tri
,
args
,
kwargs
=
Triangulation
.
get_from_args_and_kwargs
(
*
args
,
**
kwargs
)
x
=
tri
.
x
y
=
tri
.
y
edges
=
tri
.
edges
# If draw both lines and markers at the same time, e.g.
# ax.plot(x[edges].T, y[edges].T, *args, **kwargs)
# then the markers are drawn more than once which is incorrect if alpha<1.
# Hence draw lines and markers separately.
# Decode plot format string, e.g. 'ro-'
fmt
=
''
if
len
(
args
)
>
0
:
fmt
=
args
[
0
]
linestyle
,
marker
,
color
=
matplotlib
.
axes
.
_process_plot_format
(
fmt
)
# Draw lines without markers, if lines are required.
if
linestyle
is
not
None
and
linestyle
is
not
'None'
:
kw
=
kwargs
.
copy
()
kw
.
pop
(
'marker'
,
None
)
# Ignore marker if set.
kw
[
'linestyle'
]
=
ls_mapper
[
linestyle
]
kw
[
'edgecolor'
]
=
color
kw
[
'facecolor'
]
=
None
vertices
=
np
.
column_stack
((
x
[
edges
].
flatten
(),
y
[
edges
].
flatten
()))
codes
=
([
Path
.
MOVETO
]
+
[
Path
.
LINETO
])
*
len
(
edges
)
path
=
Path
(
vertices
,
codes
)
pathpatch
=
PathPatch
(
path
,
**
kw
)
ax
.
add_patch
(
pathpatch
)
# Draw markers without lines.
# Should avoid drawing markers for points that are not in any triangle?
kwargs
[
'linestyle'
]
=
''
ax
.
plot
(
x
,
y
,
*
args
,
**
kwargs
)
Back
|
FazBrowse Home
|
New Git URL