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

Commit00495d9

Browse files
committed
Merge pull request#6907 from has2k1/filled-plus-x-markers
[MRG+1] Filled + and x markers
1 parent723f889 commit00495d9

File tree

5 files changed

+98
-2
lines changed

5 files changed

+98
-2
lines changed
Lines 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

Lines 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+
ifnotself._half_fill():
861+
self._path=self._plus_filled_path
862+
else:
863+
# Rotate top half path to support all partitions
864+
iffs=='top':
865+
rotate,rotate_alt=0,180
866+
eliffs=='bottom':
867+
rotate,rotate_alt=180,0
868+
eliffs=='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+
ifnotself._half_fill():
902+
self._path=self._x_filled_path
903+
else:
904+
# Rotate top half path to support all partitions
905+
iffs=='top':
906+
rotate,rotate_alt=0,180
907+
eliffs=='bottom':
908+
rotate,rotate_alt=180,0
909+
eliffs=='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)

‎lib/matplotlib/tests/test_lines.py

Lines 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)

[8]ページ先頭

©2009-2025 Movatter.jp