Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 32a0122

Browse files
committed
DOC: add patch section
1 parent 05e001e commit 32a0122

File tree

1 file changed

+64
-5
lines changed

1 file changed

+64
-5
lines changed

doc/users/dflt_style_changes.rst

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ In addition to changing the colors, an additional method to specify
8080
colors was added. Previously, the default colors were the single
8181
character short-hand notations for red, green, blue, cyan, magenta,
8282
yellow, and black. This made them easy to type and usable in the
83-
abbreviated style string in ``plot``. On the other hand, the new
84-
colors are only specified via a hex value. To make it easier to access
85-
these colors, the notation ``'CN'`` was added to denote the first 10 colors in
86-
``mpl.rcParams['axes.prop_cycle']``. See :ref:`colors` for more details.
83+
abbreviated style string in ``plot``, however the new default colors
84+
are only specified via hex values. To access these colors outside of
85+
the property cycling the notation for colors ``'CN'`` was added to
86+
denote the first 10 colors in ``mpl.rcParms['axes.prop_cycle']`` See
87+
:ref:`colors` for more details.
8788

88-
To restore only the old color cycle use
89+
To restore the old color cycle use
8990

9091
.. code::
9192
@@ -100,6 +101,7 @@ or setting
100101
101102
in your :file:`matplotlibrc` file.
102103

104+
103105
Colormap
104106
--------
105107

@@ -316,6 +318,63 @@ or by setting::
316318

317319
in your :file:`matplotlibrc` file.
318320

321+
Patch edges and color
322+
---------------------
323+
324+
Artists drawn with a patch (``~matplotlib.axes.Axes.bar``,
325+
``~matplotlib.axes.Axes.pie``, etc) no longer have a black edge by
326+
default. The default face color is now ``'C0'`` instead of ``'b'``.
327+
328+
.. plot::
329+
330+
import matplotlib.pyplot as plt
331+
import numpy as np
332+
from matplotlib import rc_context
333+
import matplotlib.patches as mpatches
334+
335+
fig, all_ax = plt.subplots(3, 2, figsize=(4, 6), tight_layout=True)
336+
337+
def demo(ax_top, ax_mid, ax_bottom, rcparams, label):
338+
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
339+
fracs = [15, 30, 45, 10]
340+
341+
explode = (0, 0.05, 0, 0)
342+
343+
ax_top.set_title(label)
344+
345+
with rc_context(rc=rcparams):
346+
ax_top.pie(fracs, labels=labels)
347+
ax_top.set_aspect('equal')
348+
ax_mid.bar(range(len(fracs)), fracs, tick_label=labels, align='center')
349+
plt.setp(ax_mid.get_xticklabels(), rotation=-45)
350+
grid = np.mgrid[0.2:0.8:3j, 0.2:0.8:3j].reshape(2, -1).T
351+
352+
ax_bottom.set_xlim(0, .75)
353+
ax_bottom.set_ylim(0, .75)
354+
ax_bottom.add_artist(mpatches.Rectangle(grid[1] - [0.025, 0.05], 0.05, 0.1))
355+
ax_bottom.add_artist(mpatches.RegularPolygon(grid[3], 5, 0.1))
356+
ax_bottom.add_artist(mpatches.Ellipse(grid[4], 0.2, 0.1))
357+
ax_bottom.add_artist(mpatches.Circle(grid[0], 0.1))
358+
ax_bottom.axis('off')
359+
360+
demo(*all_ax[:, 0], rcparams={'patch.force_edgecolor': True,
361+
'patch.facecolor': 'b'}, label='classic')
362+
demo(*all_ax[:, 1], rcparams={}, label='v2.0')
363+
364+
The previous defaults can be restored by setting::
365+
366+
mpl.rcParams['patch.force_edgecolor'] = True
367+
mpl.rcParams['patch.facecolor'] = True
368+
369+
or by setting::
370+
371+
patch.facecolor : b
372+
patch.force_edgecolor : True
373+
374+
in your :file:`matplotlibrc` file.
375+
376+
377+
319378
Other
320379
=====
321380

0 commit comments

Comments
 (0)