Skip to content

Commit 187a881

Browse files
committed
Merge remote-tracking branch 'matplotlib/v2.x'
Conflicts: examples/api/image_zcoord.py - whitespace vs random seed, kept seed lib/matplotlib/axes/_base.py - unclear what these conflicts are from, text was identical lib/matplotlib/testing/decorators.py - conflict due to backporting changs that were super-sceded on master lib/matplotlib/tests/test_ticker.py - just adust the cleanup decorator
2 parents 7bb4cad + 6985632 commit 187a881

39 files changed

+2748
-2427
lines changed

doc/users/dflt_style_changes.rst

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -597,17 +597,20 @@ To restore the previous behavior explicitly pass the keyword argument
597597
Hatching
598598
========
599599

600-
The width of the lines in a hatch pattern is now configurable by the
601-
rcParam `hatch.linewidth`, with a default of 1 point. The old
602-
behavior was different depending on backend:
600+
The color and width of the lines in a hatch pattern are now configurable by the
601+
rcParams `hatch.color` and `hatch.linewidth`, with defaults of black and 1
602+
point, respectively. The old behaviour for the color was to apply the edge
603+
color or use black, depending on the artist; the old behavior for the line
604+
width was different depending on backend:
603605

604606
- PDF: 0.1 pt
605607
- SVG: 1.0 pt
606608
- PS: 1 px
607609
- Agg: 1 px
608610

609-
The old behavior can not be restored across all backends simultaneously, but
610-
can be restored for a single backend by setting::
611+
The old color behavior can not be restored. The old line width behavior can not
612+
be restored across all backends simultaneously, but can be restored for a
613+
single backend by setting::
611614

612615
mpl.rcParams['hatch.linewidth'] = 0.1 # previous pdf hatch linewidth
613616
mpl.rcParams['hatch.linewidth'] = 1.0 # previous svg hatch linewidth
@@ -620,7 +623,7 @@ The behavior of the PS and Agg backends was DPI dependent, thus::
620623
mpl.rcParams['hatch.linewidth'] = 1.0 / dpi # previous ps and Agg hatch linewidth
621624

622625

623-
There is no API level control of the hatch linewidth.
626+
There is no API level control of the hatch color or linewidth.
624627

625628

626629
.. _default_changes_font:
@@ -1065,6 +1068,17 @@ Z-order
10651068

10661069

10671070

1071+
``ScalarFormatter`` tick label formatting with offsets
1072+
======================================================
1073+
1074+
With the default of ``rcParams['axes.formatter.useoffset'] = True``,
1075+
an offset will be used when it will save 4 or more digits. This can
1076+
be controlled with the new rcParam, ``axes.formatter.offset_threshold``.
1077+
To restore the previous behavior of using an offset to save 2 or more
1078+
digits, use ``rcParams['axes.formatter.offset_threshold'] = 2``.
1079+
1080+
1081+
10681082
``AutoDateFormatter`` format strings
10691083
====================================
10701084

doc/users/whats_new.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,16 @@ New rcparams added
8282
|`ytick.minor.right`, | |
8383
|`ytick.major.right` | |
8484
+---------------------------------+--------------------------------------------------+
85-
|`hist.bins` | the default number of bins to use in |
85+
|`hist.bins` | The default number of bins to use in |
8686
| | `~matplotlib.axes.Axes.hist`. This can be an |
8787
| | `int`, a list of floats, or ``'auto'`` if numpy |
8888
| | >= 1.11 is installed. |
8989
+---------------------------------+--------------------------------------------------+
90-
|`lines.scale_dashes` | If the line dash patterns should scale with |
91-
| | linewidth |
90+
|`lines.scale_dashes` | Whether the line dash patterns should scale with |
91+
| | linewidth. |
92+
+---------------------------------+--------------------------------------------------+
93+
|`axes.formatter.offset_threshold`| Minimum number of digits saved in tick labels |
94+
| | that triggers using an offset. |
9295
+---------------------------------+--------------------------------------------------+
9396

9497

examples/pylab_examples/log_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
plt.subplot(223)
2222
plt.loglog(t, 20*np.exp(-t/10.0), basex=2)
2323
plt.grid(True)
24-
plt.title('loglog base 4 on x')
24+
plt.title('loglog base 2 on x')
2525

2626
# with errorbars: clip non-positive values
2727
ax = plt.subplot(224)

lib/matplotlib/backend_bases.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ def __init__(self):
789789
self._linewidth = 1
790790
self._rgb = (0.0, 0.0, 0.0, 1.0)
791791
self._hatch = None
792+
self._hatch_color = colors.to_rgba(rcParams['hatch.color'])
792793
self._hatch_linewidth = rcParams['hatch.linewidth']
793794
self._url = None
794795
self._gid = None
@@ -1086,6 +1087,12 @@ def get_hatch_path(self, density=6.0):
10861087
return None
10871088
return Path.hatch(self._hatch, density)
10881089

1090+
def get_hatch_color(self):
1091+
"""
1092+
Gets the color to use for hatching.
1093+
"""
1094+
return self._hatch_color
1095+
10891096
def get_hatch_linewidth(self):
10901097
"""
10911098
Gets the linewidth to use for hatching.

lib/matplotlib/backends/backend_pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2227,7 +2227,7 @@ def hatch_cmd(self, hatch):
22272227
else:
22282228
return [Name('DeviceRGB'), Op.setcolorspace_nonstroke]
22292229
else:
2230-
hatch_style = (self._rgb, self._fillcolor, hatch)
2230+
hatch_style = (self._hatch_color, self._fillcolor, hatch)
22312231
name = self.file.hatchPattern(hatch_style)
22322232
return [Name('Pattern'), Op.setcolorspace_nonstroke,
22332233
name, Op.setcolor_nonstroke]

lib/matplotlib/backends/backend_ps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ def _draw_ps(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
890890
if hatch:
891891
hatch_name = self.create_hatch(hatch)
892892
write("gsave\n")
893-
write("[/Pattern [/DeviceRGB]] setcolorspace %f %f %f " % gc.get_rgb()[:3])
893+
write("[/Pattern [/DeviceRGB]] setcolorspace %f %f %f " % gc.get_hatch_color()[:3])
894894
write("%s setcolor fill grestore\n" % hatch_name)
895895

896896
if stroke:

lib/matplotlib/backends/backend_svg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def _get_hatch(self, gc, rgbFace):
349349
"""
350350
if rgbFace is not None:
351351
rgbFace = tuple(rgbFace)
352-
edge = gc.get_rgb()
352+
edge = gc.get_hatch_color()
353353
if edge is not None:
354354
edge = tuple(edge)
355355
dictkey = (gc.get_hatch(), rgbFace, edge)

lib/matplotlib/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ def contains(self, mouseevent):
524524

525525
def write_png(self, fname):
526526
"""Write the image to png file with fname"""
527-
im = self.to_rgba(self._A, bytes=True, norm=False)
527+
im = self.to_rgba(self._A, bytes=True, norm=True)
528528
_png.write_png(im, fname)
529529

530530
def set_data(self, A):

lib/matplotlib/mpl-data/stylelib/classic.mplstyle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ patch.force_edgecolor : True
3434
patch.edgecolor : k
3535
patch.antialiased : True # render patches in antialiased (no jaggies)
3636

37+
hatch.color : k
3738
hatch.linewidth : 1.0
3839

3940
hist.bins : 10
@@ -204,6 +205,10 @@ axes.formatter.useoffset : True # If True, the tick label formatter
204205
# to an offset when the data range is very
205206
# small compared to the minimum absolute
206207
# value of the data.
208+
axes.formatter.offset_threshold : 2 # When useoffset is True, the offset
209+
# will be used when it can remove
210+
# at least this number of significant
211+
# digits from tick labels.
207212

208213
axes.unicode_minus : True # use unicode for the minus symbol
209214
# rather than hyphen. See

lib/matplotlib/rcsetup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ def validate_hatch(s):
682682
raise ValueError("Unknown hatch symbol(s): %s" % list(unknown))
683683
return s
684684
validate_hatchlist = _listify_validator(validate_hatch)
685-
685+
validate_dashlist = _listify_validator(validate_nseq_float())
686686

687687
_prop_validators = {
688688
'color': _listify_validator(validate_color_for_prop_cycle,
@@ -701,6 +701,7 @@ def validate_hatch(s):
701701
'alpha': validate_floatlist,
702702
'marker': validate_stringlist,
703703
'hatch': validate_hatchlist,
704+
'dashes': validate_dashlist,
704705
}
705706
_prop_aliases = {
706707
'c': 'color',
@@ -930,6 +931,7 @@ def validate_animation_writer_path(p):
930931
'patch.antialiased': [True, validate_bool], # antialiased (no jaggies)
931932

932933
## hatch props
934+
'hatch.color': ['k', validate_color],
933935
'hatch.linewidth': [1.0, validate_float],
934936

935937
## Histogram properties
@@ -1085,6 +1087,7 @@ def validate_animation_writer_path(p):
10851087
# Use the current locale to format ticks
10861088
'axes.formatter.use_mathtext': [False, validate_bool],
10871089
'axes.formatter.useoffset': [True, validate_bool],
1090+
'axes.formatter.offset_threshold': [4, validate_int],
10881091
'axes.unicode_minus': [True, validate_bool],
10891092
'axes.color_cycle': [
10901093
['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728',

0 commit comments

Comments
 (0)