Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc858831

Browse files
committed
DOCS: render JoinStyle/CapStyle better
1 parenta46278c commitc858831

File tree

3 files changed

+66
-32
lines changed

3 files changed

+66
-32
lines changed

‎doc/_static/mpl.css

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ table.highlighttable td {
8989
padding:00.5em00.5em;
9090
}
9191

92-
cite,code,tt {
92+
cite,code,tt,dl.value-listdt {
9393
font-family:'Consolas','Deja Vu Sans Mono','Bitstream Vera Sans Mono', monospace;
9494
font-size:0.95em;
9595
letter-spacing:0.01em;
@@ -730,7 +730,6 @@ td.field-body table.property-table tr:last-of-type td {
730730
border-bottom-color:#888;
731731
}
732732

733-
734733
/* function and class description */
735734
.descclassname {
736735
color:#aaa;
@@ -806,6 +805,22 @@ dl.class > dd {
806805
font-size:14px;
807806
}
808807

808+
/* custom tables for lists of allowed values in "mpl._types" */
809+
dl.value-list {
810+
display: grid;
811+
}
812+
813+
dl.value-listdt {
814+
grid-column:1;
815+
margin:4px0;
816+
}
817+
818+
dl.value-listdd {
819+
grid-column:2;
820+
margin:4px04px20px;
821+
padding:0;
822+
}
823+
809824
/* parameter section table */
810825
table.docutils.field-list {
811826
width:100%;
@@ -1257,4 +1272,4 @@ div.bullet-box li {
12571272

12581273
div#gallery.section .sphx-glr-clear:first-of-type,div#tutorials.section .sphx-glr-clear:first-of-type{
12591274
display: none;
1260-
}
1275+
}

‎doc/api/_types.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
..automodule::matplotlib._types
66
:no-members:
7-
:show-inheritance:
8-
9-
..autodata::_AutoStringNameEnum
107

118
..autoclass::JoinStyle
129
:members: demo

‎lib/matplotlib/_types.py

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
"""
2-
Types that would not normally have their own class are documented here.
2+
Concepts used by the matplotlib API that do not yet have a dedicated class.
3+
4+
Matplotlib often uses simple data types like strings or tuples to define a
5+
concept; e.g. the line capstyle can be specified as one of 'butt', 'round',
6+
or 'projecting'. The classes in this module are used internally and document
7+
these concepts formally.
8+
9+
As an end-user you will not use these classes directly, but only the values
10+
they define.
311
"""
412

513
fromenumimportEnum,auto
@@ -48,25 +56,29 @@ class JoinStyle(str, _AutoStringNameEnum):
4856
4957
**Supported values:**
5058
51-
- *miter*: the "arrow-tip" style. Each boundary of the filled-in area
52-
will extend in a straight line parallel to the tangent vector of the
53-
centerline at the point it meets the corner, until they meet in a
54-
sharp point.
55-
- *round*: stokes every point within a radius of ``linewidth/2`` of the
56-
center lines.
57-
- *bevel*: the "squared-off" style. It can be thought of as a rounded
58-
corner where the "circular" part of the corner has been cut off.
59+
.. rst-class:: value-list
60+
61+
'miter'
62+
the "arrow-tip" style. Each boundary of the filled-in area will
63+
extend in a straight line parallel to the tangent vector of the
64+
centerline at the point it meets the corner, until they meet in a
65+
sharp point.
66+
'round'
67+
stokes every point within a radius of ``linewidth/2`` of the center
68+
lines.
69+
'bevel'
70+
the "squared-off" style. It can be thought of as a rounded corner
71+
where the "circular" part of the corner has been cut off.
5972
6073
.. note::
6174
62-
The *miter* option can be controlled further by specifying a "miter
63-
limit", which specifies how long a miter tip can get before it is
64-
automatically "bevel"ed off. Matplotlib does not currently expose a
65-
``miterlimit`` parameter to the user, and most backends simply use the
66-
upstream default value. For example, the PDF backend assumes the
67-
default value of 10 specified by the PDF standard, while the SVG
68-
backend does not even specify the miter limit, resulting in a default
69-
value of 4 per the SVG specification.
75+
Very long miter tips are cut off (to form a *bevel*) after a
76+
backend-dependent limit called the "miter limit", which specifies the
77+
maximum allowed ratio of miter length to line width. For example, the
78+
PDF backend uses the default value of 10 specified by the PDF standard,
79+
while the SVG backend does not even specify the miter limit, resulting
80+
in a default value of 4 per the SVG specification. Matplotlib does not
81+
currently allow the user to adjust this parameter.
7082
7183
A more detailed description of the effect of a miter limit can be found
7284
in the `Mozilla Developer Docs
@@ -102,7 +114,7 @@ def plot_angle(ax, x, y, angle, style):
102114
ax.plot(xx,yy,lw=1,color='black')
103115
ax.plot(xx[1],yy[1],'o',color='tab:red',markersize=3)
104116

105-
fig,ax=plt.subplots(figsize=(8,6))
117+
fig,ax=plt.subplots(figsize=(5,4),constrained_layout=True)
106118
ax.set_title('Join style')
107119
forx,styleinenumerate(['miter','round','bevel']):
108120
ax.text(x,5,style)
@@ -114,6 +126,8 @@ def plot_angle(ax, x, y, angle, style):
114126
ax.set_ylim(-.5,5.5)
115127
ax.set_axis_off()
116128
fig.show()
129+
130+
117131
JoinStyle.input_description="{" \
118132
+", ".join([f"'{js.name}'"forjsinJoinStyle]) \
119133
+"}"
@@ -133,11 +147,16 @@ class CapStyle(str, _AutoStringNameEnum):
133147
134148
**Supported values:**
135149
136-
- *butt*: the line is squared off at its endpoint.
137-
- *projecting*: the line is squared off as in *butt*, but the filled in
138-
area extends beyond the endpoint a distance of ``linewidth/2``.
139-
- *round*: like *butt*, but a semicircular cap is added to the end of
140-
the line, of radius ``linewidth/2``.
150+
.. rst-class:: value-list
151+
152+
'butt'
153+
the line is squared off at its endpoint.
154+
'projecting'
155+
the line is squared off as in *butt*, but the filled in area
156+
extends beyond the endpoint a distance of ``linewidth/2``.
157+
'round'
158+
like *butt*, but a semicircular cap is added to the end of the
159+
line, of radius ``linewidth/2``.
141160
142161
.. plot::
143162
:alt: Demo of possible CapStyle's
@@ -159,21 +178,24 @@ def demo():
159178
"""Demonstrate how each CapStyle looks for a thick line segment."""
160179
importmatplotlib.pyplotasplt
161180

162-
fig,ax=plt.subplots(figsize=(8,2))
181+
fig=plt.figure(figsize=(4,1.2))
182+
ax=fig.add_axes([0,0,1,0.8])
163183
ax.set_title('Cap style')
164184

165185
forx,styleinenumerate(['butt','round','projecting']):
166-
ax.text(x+0.25,1,style,ha='center')
186+
ax.text(x+0.25,0.85,style,ha='center')
167187
xx= [x,x+0.5]
168188
yy= [0,0]
169189
ax.plot(xx,yy,lw=12,color='tab:blue',solid_capstyle=style)
170190
ax.plot(xx,yy,lw=1,color='black')
171191
ax.plot(xx,yy,'o',color='tab:red',markersize=3)
172-
ax.text(2.25,0.7,'(default)',ha='center')
192+
ax.text(2.25,0.55,'(default)',ha='center')
173193

174194
ax.set_ylim(-.5,1.5)
175195
ax.set_axis_off()
176196
fig.show()
197+
198+
177199
CapStyle.input_description="{" \
178200
+", ".join([f"'{cs.name}'"forcsinCapStyle]) \
179201
+"}"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp