Skip to content

Commit f4ab8a2

Browse files
committed
proposed norm/center specs in MarkerStyle.__init__
1 parent c4628b7 commit f4ab8a2

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

lib/matplotlib/markers.py

+33-7
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@
143143
_empty_path = Path(np.empty((0, 2)))
144144

145145

146+
normalization_options = ["none", "classic", "bbox", "bbox-width", "bbox-area",
147+
"area"]
148+
centering_options = ["none", "classic", "bbox", "mass"]
149+
150+
146151
class MarkerStyle:
147152

148153
markers = {
@@ -202,7 +207,7 @@ class MarkerStyle:
202207
_point_size_reduction = 0.5
203208

204209
def __init__(self, marker=None, fillstyle=None, *,
205-
normalization="classic"):
210+
normalization="classic", centering="classic"):
206211
"""
207212
Attributes
208213
----------
@@ -221,16 +226,30 @@ def __init__(self, marker=None, fillstyle=None, *,
221226
fillstyle : str, optional, default: 'full'
222227
'full', 'left", 'right', 'bottom', 'top', 'none'
223228
224-
normalization : str, {'classic', 'none'}, optional, default: "classic"
225-
The normalization of the marker size. Only applies to custom paths
226-
that are provided as array of vertices or `~.path.Path`.
227-
Can take two values:
228-
*'classic'*, being the default, makes sure the marker path is
229-
normalized to fit within a unit-square by affine scaling.
229+
normalization : str, optional, default: "classic"
230+
The normalization of the marker size. Can take several values:
231+
*'classic'*, being the default, makes sure custom marker paths are
232+
normalized to fit within a unit-square by affine scaling (but
233+
leaves built-in markers as-is).
234+
*'bbox-width'*, ensure marker path fits in the unit square.
235+
*'area'*, rescale so the marker path has unit "signed_area".
236+
*'bbox-area'*, rescale so that the marker path's bbox has unit
237+
area.
230238
*'none'*, in which case no scaling is performed on the marker path.
239+
240+
centering : str, optional, default: "classic"
241+
The centering of the marker. Can take several values:
242+
*'none'*, being the default, does not translate the marker path.
243+
The origin in path coordinates is the marker center in this case.
244+
*'bbox'*, translates the marker path so that its bbox's center is
245+
at the origin.
246+
*'center-of-mass'*, translates the marker path so that its center
247+
of mass it as the origin. See Path.center_of_mass for details.
231248
"""
232249
cbook._check_in_list(["classic", "none"], normalization=normalization)
250+
cbook._check_in_list(["centering", "none"], centering=centering)
233251
self._normalize = normalization
252+
self._center = centering
234253
self._marker_function = None
235254
self.set_fillstyle(fillstyle)
236255
self.set_marker(marker)
@@ -319,6 +338,13 @@ def set_transform(self, transform):
319338
"""
320339
Sets the transform of the marker. This is the transform by which the
321340
marker path is transformed.
341+
342+
In order to change the marker relative to its current state, make sure
343+
to compose with the current transform. Remember that the transform on
344+
the left of the addition side is applied first. For example:
345+
346+
>>> spin = mpl.transforms.Affine2D().rotate_deg(90)
347+
>>> marker.set_transform(marker.get_transform() + spin)
322348
"""
323349
self._transform = transform
324350

0 commit comments

Comments
 (0)