|
55 | 55 | from matplotlib import is_interactive |
56 | 56 | from matplotlib import get_backend |
57 | 57 | from matplotlib._pylab_helpers import Gcf |
| 58 | +from matplotlib import lines |
58 | 59 |
|
59 | 60 | from matplotlib.transforms import Bbox, TransformedBbox, Affine2D |
60 | 61 |
|
@@ -771,14 +772,6 @@ class GraphicsContextBase(object): |
771 | 772 | An abstract base class that provides color, line styles, etc... |
772 | 773 | """ |
773 | 774 |
|
774 | | - # a mapping from dash styles to suggested offset, dash pairs |
775 | | - dashd = { |
776 | | - 'solid': (None, None), |
777 | | - 'dashed': (0, (6.0, 6.0)), |
778 | | - 'dashdot': (0, (3.0, 5.0, 1.0, 5.0)), |
779 | | - 'dotted': (0, (1.0, 3.0)), |
780 | | - } |
781 | | - |
782 | 775 | def __init__(self): |
783 | 776 | self._alpha = 1.0 |
784 | 777 | self._forced_alpha = False # if True, _alpha overrides A from RGBA |
@@ -870,7 +863,16 @@ def get_dashes(self): |
870 | 863 |
|
871 | 864 | Default value is None |
872 | 865 | """ |
873 | | - return self._dashes |
| 866 | + if rcParams['_internal.classic_mode']: |
| 867 | + return self._dashes |
| 868 | + else: |
| 869 | + scale = max(1.0, self.get_linewidth()) |
| 870 | + offset, dashes = self._dashes |
| 871 | + if offset is not None: |
| 872 | + offset = offset * scale |
| 873 | + if dashes is not None: |
| 874 | + dashes = [x * scale for x in dashes] |
| 875 | + return offset, dashes |
874 | 876 |
|
875 | 877 | def get_forced_alpha(self): |
876 | 878 | """ |
@@ -1047,21 +1049,12 @@ def set_linewidth(self, w): |
1047 | 1049 | def set_linestyle(self, style): |
1048 | 1050 | """ |
1049 | 1051 | Set the linestyle to be one of ('solid', 'dashed', 'dashdot', |
1050 | | - 'dotted'). One may specify customized dash styles by providing |
1051 | | - a tuple of (offset, dash pairs). For example, the predefiend |
1052 | | - linestyles have following values.: |
1053 | | -
|
1054 | | - 'dashed' : (0, (6.0, 6.0)), |
1055 | | - 'dashdot' : (0, (3.0, 5.0, 1.0, 5.0)), |
1056 | | - 'dotted' : (0, (1.0, 3.0)), |
| 1052 | + 'dotted'). These are defined in the rcParams |
| 1053 | + `lines.dashed_pattern`, `lines.dashdot_pattern` and |
| 1054 | + `lines.dotted_pattern`. One may also specify customized dash |
| 1055 | + styles by providing a tuple of (offset, dash pairs). |
1057 | 1056 | """ |
1058 | | - |
1059 | | - if style in self.dashd: |
1060 | | - offset, dashes = self.dashd[style] |
1061 | | - elif isinstance(style, tuple): |
1062 | | - offset, dashes = style |
1063 | | - else: |
1064 | | - raise ValueError('Unrecognized linestyle: %s' % str(style)) |
| 1057 | + offset, dashes = lines.get_dash_pattern(style) |
1065 | 1058 |
|
1066 | 1059 | self._linestyle = style |
1067 | 1060 | self.set_dashes(offset, dashes) |
|
0 commit comments