|
4 | 4 | `~matplotlib.axes.Axes.scatter`. |
5 | 5 | """ |
6 | 6 |
|
| 7 | +import textwrap |
| 8 | + |
7 | 9 | import numpy as np |
8 | 10 |
|
9 | 11 | from cbook import is_math_text, is_string_like, is_numlike, iterable |
| 12 | +import docstring |
10 | 13 | from matplotlib import rcParams |
11 | 14 | from path import Path |
12 | 15 | from transforms import IdentityTransform, Affine2D |
|
17 | 20 |
|
18 | 21 | class MarkerStyle: |
19 | 22 | style_table = """ |
20 | | -======================== ===================================================== |
21 | | -marker description |
22 | | -======================== ===================================================== |
| 23 | +============================== =============================================== |
| 24 | +marker description |
| 25 | +============================== =============================================== |
23 | 26 | %s |
24 | | -``'$...$'`` render the string using mathtext |
25 | | -(numsides, style, angle) see below |
26 | | -verts where verts is a list of (x, y) pairs in range (0, 1) |
27 | | -======================== ===================================================== |
28 | | -
|
29 | | -TODO: Describe tuple form |
| 27 | +``'$...$'`` render the string using mathtext |
| 28 | +*verts* a list of (x, y) pairs in range (0, 1) |
| 29 | +(*numsides*, *style*, *angle*) see below |
| 30 | +============================== =============================================== |
| 31 | +
|
| 32 | +The marker can also be a tuple (*numsides*, *style*, *angle*), which |
| 33 | +will create a custom, regular symbol. |
| 34 | +
|
| 35 | + *numsides*: |
| 36 | + the number of sides |
| 37 | +
|
| 38 | + *style*: |
| 39 | + the style of the regular symbol: |
| 40 | +
|
| 41 | + ===== ============================================= |
| 42 | + Value Description |
| 43 | + ===== ============================================= |
| 44 | + 0 a regular polygon |
| 45 | + 1 a star-like symbol |
| 46 | + 2 an asterisk |
| 47 | + 3 a circle (*numsides* and *angle* is ignored) |
| 48 | + ===== ============================================= |
| 49 | +
|
| 50 | + *angle*: |
| 51 | + the angle of rotation of the symbol |
| 52 | +
|
| 53 | +For backward compatibility, the form (*verts*, 0) is also accepted, |
| 54 | +but it is equivalent to just *verts* for giving a raw set of vertices |
| 55 | +that define the shape. |
30 | 56 | """ |
31 | 57 |
|
32 | 58 | # TODO: Automatically generate this |
33 | | - accepts = """ACCEPTS: [ %s | ``'$...$'`` | tuple ]""" |
| 59 | + accepts = """ACCEPTS: [ %s | ``'$...$'`` | *tuple* | *Nx2 array* ]""" |
34 | 60 |
|
35 | 61 | markers = { |
36 | 62 | '.' : 'point', |
@@ -603,11 +629,14 @@ def _set_x(self): |
603 | 629 | self._path = self._x_path |
604 | 630 |
|
605 | 631 | _styles = [(repr(x), y) for x, y in MarkerStyle.markers.items()] |
606 | | -_styles.sort() |
| 632 | +_styles.sort(lambda x, y: cmp(x[1], y[1])) |
607 | 633 | MarkerStyle.style_table = ( |
608 | 634 | MarkerStyle.style_table % |
609 | | - '\n'.join(['``%7s`` %33s' % (x, y) for (x, y) in _styles])) |
| 635 | + '\n'.join(['%-30s %-33s' % ('``%s``' % x, y) for (x, y) in _styles])) |
610 | 636 |
|
611 | | -MarkerStyle.accepts = ( |
| 637 | +MarkerStyle.accepts = textwrap.fill( |
612 | 638 | MarkerStyle.accepts % |
613 | 639 | ' | '.join(['``%s``' % x for (x, y) in _styles])) |
| 640 | + |
| 641 | +docstring.interpd.update(MarkerTable=MarkerStyle.style_table) |
| 642 | +docstring.interpd.update(MarkerAccepts=MarkerStyle.accepts) |
0 commit comments