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

Appearance settings

Commit 00495d9

Browse filesBrowse files
committed
Merge pull request #6907 from has2k1/filled-plus-x-markers
[MRG+1] Filled + and x markers
1 parent 723f889 commit 00495d9
Copy full SHA for 00495d9

File tree

Expand file treeCollapse file tree

5 files changed

+98
-2
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+98
-2
lines changed
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Filled ``+`` and ``x`` markers
2+
------------------------------
3+
4+
New fillable *plus* and *x* markers have been added. See
5+
the :mod:`~matplotlib.markers` module and
6+
:ref:`marker reference <lines_bars_and_markers-marker_reference>`
7+
examples.

‎lib/matplotlib/markers.py

Copy file name to clipboardExpand all lines: lib/matplotlib/markers.py
+90-1Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
"d" thin_diamond
3232
"|" vline
3333
"_" hline
34+
"P" plus (filled)
35+
"X" x (filled)
3436
TICKLEFT tickleft
3537
TICKRIGHT tickright
3638
TICKUP tickup
@@ -124,6 +126,8 @@ class MarkerStyle(object):
124126
'd': 'thin_diamond',
125127
'|': 'vline',
126128
'_': 'hline',
129+
'P': 'plus_filled',
130+
'X': 'x_filled',
127131
TICKLEFT: 'tickleft',
128132
TICKRIGHT: 'tickright',
129133
TICKUP: 'tickup',
@@ -145,7 +149,8 @@ class MarkerStyle(object):
145149
# Just used for informational purposes. is_filled()
146150
# is calculated in the _set_* functions.
147151
filled_markers = (
148-
'o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd')
152+
'o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd',
153+
'P', 'X')
149154

150155
fillstyles = ('full', 'left', 'right', 'bottom', 'top', 'none')
151156
_half_fillstyles = ('left', 'right', 'bottom', 'top')
@@ -827,3 +832,87 @@ def _set_x(self):
827832
self._snap_threshold = 3.0
828833
self._filled = False
829834
self._path = self._x_path
835+
836+
_plus_filled_path = Path([(1/3, 0), (2/3, 0), (2/3, 1/3),
837+
(1, 1/3), (1, 2/3), (2/3, 2/3),
838+
(2/3, 1), (1/3, 1), (1/3, 2/3),
839+
(0, 2/3), (0, 1/3), (1/3, 1/3),
840+
(1/3, 0)],
841+
[Path.MOVETO, Path.LINETO, Path.LINETO,
842+
Path.LINETO, Path.LINETO, Path.LINETO,
843+
Path.LINETO, Path.LINETO, Path.LINETO,
844+
Path.LINETO, Path.LINETO, Path.LINETO,
845+
Path.CLOSEPOLY])
846+
847+
_plus_filled_path_t = Path([(1, 1/2), (1, 2/3), (2/3, 2/3),
848+
(2/3, 1), (1/3, 1), (1/3, 2/3),
849+
(0, 2/3), (0, 1/2), (1, 1/2)],
850+
[Path.MOVETO, Path.LINETO, Path.LINETO,
851+
Path.LINETO, Path.LINETO, Path.LINETO,
852+
Path.LINETO, Path.LINETO,
853+
Path.CLOSEPOLY])
854+
855+
def _set_plus_filled(self):
856+
self._transform = Affine2D().translate(-0.5, -0.5)
857+
self._snap_threshold = 5.0
858+
self._joinstyle = 'miter'
859+
fs = self.get_fillstyle()
860+
if not self._half_fill():
861+
self._path = self._plus_filled_path
862+
else:
863+
# Rotate top half path to support all partitions
864+
if fs == 'top':
865+
rotate, rotate_alt = 0, 180
866+
elif fs == 'bottom':
867+
rotate, rotate_alt = 180, 0
868+
elif fs == 'left':
869+
rotate, rotate_alt = 90, 270
870+
else:
871+
rotate, rotate_alt = 270, 90
872+
873+
self._path = self._plus_filled_path_t
874+
self._alt_path = self._plus_filled_path_t
875+
self._alt_transform = Affine2D().translate(-0.5, -0.5)
876+
self._transform.rotate_deg(rotate)
877+
self._alt_transform.rotate_deg(rotate_alt)
878+
879+
_x_filled_path = Path([(0.25, 0), (0.5, 0.25), (0.75, 0), (1, 0.25),
880+
(0.75, 0.5), (1, 0.75), (0.75, 1), (0.5, 0.75),
881+
(0.25, 1), (0, 0.75), (0.25, 0.5), (0, 0.25),
882+
(0.25, 0)],
883+
[Path.MOVETO, Path.LINETO, Path.LINETO,
884+
Path.LINETO, Path.LINETO, Path.LINETO,
885+
Path.LINETO, Path.LINETO, Path.LINETO,
886+
Path.LINETO, Path.LINETO, Path.LINETO,
887+
Path.CLOSEPOLY])
888+
889+
_x_filled_path_t = Path([(0.75, 0.5), (1, 0.75), (0.75, 1),
890+
(0.5, 0.75), (0.25, 1), (0, 0.75),
891+
(0.25, 0.5), (0.75, 0.5)],
892+
[Path.MOVETO, Path.LINETO, Path.LINETO,
893+
Path.LINETO, Path.LINETO, Path.LINETO,
894+
Path.LINETO, Path.CLOSEPOLY])
895+
896+
def _set_x_filled(self):
897+
self._transform = Affine2D().translate(-0.5, -0.5)
898+
self._snap_threshold = 5.0
899+
self._joinstyle = 'miter'
900+
fs = self.get_fillstyle()
901+
if not self._half_fill():
902+
self._path = self._x_filled_path
903+
else:
904+
# Rotate top half path to support all partitions
905+
if fs == 'top':
906+
rotate, rotate_alt = 0, 180
907+
elif fs == 'bottom':
908+
rotate, rotate_alt = 180, 0
909+
elif fs == 'left':
910+
rotate, rotate_alt = 90, 270
911+
else:
912+
rotate, rotate_alt = 270, 90
913+
914+
self._path = self._x_filled_path_t
915+
self._alt_path = self._x_filled_path_t
916+
self._alt_transform = Affine2D().translate(-0.5, -0.5)
917+
self._transform.rotate_deg(rotate)
918+
self._alt_transform.rotate_deg(rotate_alt)
Loading
Loading

‎lib/matplotlib/tests/test_lines.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_lines.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def test_marker_fill_styles():
178178
markeredgewidth=2)
179179

180180
ax.set_ylim([0, 7.5])
181-
ax.set_xlim([-5, 135])
181+
ax.set_xlim([-5, 155])
182182

183183

184184
@image_comparison(baseline_images=['scaled_lines'], style='default')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.