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

Skip to content

Commit 17edc41

Browse files
committed
Add where="between"/"edges" to step and step="between" to fill_between
1 parent f0eac06 commit 17edc41

File tree

10 files changed

+437
-21
lines changed

10 files changed

+437
-21
lines changed

doc/missing-references.json

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,111 @@
15721572
"font.*": [
15731573
"doc/users/prev_whats_new/whats_new_1.3.rst:302"
15741574
],
1575+
"_base": [
1576+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:10"
1577+
],
1578+
"axes": [
1579+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:12",
1580+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:16"
1581+
],
1582+
"_subplot": [
1583+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:14"
1584+
],
1585+
"import math": [
1586+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:20"
1587+
],
1588+
"from numpy import ma": [
1589+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:21"
1590+
],
1591+
"from matplotlib import cbook": [
1592+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:22"
1593+
],
1594+
"from matplotlib import docstring": [
1595+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:23"
1596+
],
1597+
"from matplotlib.cbook import is_sequence_of_strings": [
1598+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:24"
1599+
],
1600+
"from matplotlib.cbook import is_string_like": [
1601+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:25"
1602+
],
1603+
"from matplotlib.cbook import iterable": [
1604+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:26"
1605+
],
1606+
"import itertools": [
1607+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:27"
1608+
],
1609+
"from matplotlib import artist as martist": [
1610+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:28"
1611+
],
1612+
"import matplotlib": [
1613+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:29"
1614+
],
1615+
"from matplotlib import collections as mcoll": [
1616+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:30"
1617+
],
1618+
"from matplotlib import colors as mcolors": [
1619+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:31"
1620+
],
1621+
"from matplotlib import contour as mcontour": [
1622+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:32"
1623+
],
1624+
"from matplotlib import patches as mpatches": [
1625+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:33"
1626+
],
1627+
"from matplotlib import path as mpath": [
1628+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:34"
1629+
],
1630+
"from matplotlib import quiver as mquiver": [
1631+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:35"
1632+
],
1633+
"from matplotlib import stack as mstack": [
1634+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:36"
1635+
],
1636+
"from matplotlib import stream as mstream": [
1637+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:37"
1638+
],
1639+
"from matplotlib import table as mtable": [
1640+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:38"
1641+
],
1642+
"matplotlib.backends.qt4_compat": [
1643+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:40"
1644+
],
1645+
"matplotlib.qt_compat": [
1646+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:40"
1647+
],
1648+
"qt4_compat": [
1649+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:40"
1650+
],
1651+
"ipython_directive": [
1652+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:59"
1653+
],
1654+
"ipython_console_highlighting": [
1655+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:59"
1656+
],
1657+
"conf.py": [
1658+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:59"
1659+
],
1660+
"IPython.sphinxext.ipython_directive": [
1661+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:59"
1662+
],
1663+
"matplotlib.sphinxext.ipython_directive": [
1664+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:59"
1665+
],
1666+
"matplotlib.finance": [
1667+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:66"
1668+
],
1669+
"*_ochl": [
1670+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:66"
1671+
],
1672+
"*_ohlc": [
1673+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:66"
1674+
],
1675+
"colorbar": [
1676+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:82",
1677+
"doc/api/prev_api_changes/api_changes_1.5.0.rst:371"
1678+
],
1679+
>>>>>>> Add where="between"/"edges" to step and step="between" to fill_between
15751680
"colorbar.ColorbarBase.outline": [
15761681
"doc/api/prev_api_changes/api_changes_1.4.x.rst:83"
15771682
],
@@ -1601,6 +1706,33 @@
16011706
"doc/users/prev_whats_new/whats_new_1.4.rst:214",
16021707
"doc/users/prev_whats_new/whats_new_3.0.rst:111"
16031708
],
1709+
<<<<<<< HEAD
1710+
=======
1711+
"__init__": [
1712+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:173"
1713+
],
1714+
"fontproperties": [
1715+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:173"
1716+
],
1717+
"AnchoredSizeBar": [
1718+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:173"
1719+
],
1720+
"prop": [
1721+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:173"
1722+
],
1723+
"fontpropreties": [
1724+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:173"
1725+
],
1726+
"plt.subplot": [
1727+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:181"
1728+
],
1729+
"plt.subplots(2, 2,\n0)": [
1730+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:181"
1731+
],
1732+
"GridSpec": [
1733+
"doc/api/prev_api_changes/api_changes_1.4.x.rst:181"
1734+
],
1735+
>>>>>>> Add where="between"/"edges" to step and step="between" to fill_between
16041736
"matplotlib.cbook.ls_mapper": [
16051737
"doc/api/prev_api_changes/api_changes_1.5.0.rst:11",
16061738
"doc/api/prev_api_changes/api_changes_1.5.0.rst:8"
@@ -1645,8 +1777,16 @@
16451777
"doc/users/prev_whats_new/whats_new_2.2.rst:251",
16461778
"doc/users/prev_whats_new/whats_new_2.2.rst:254"
16471779
],
1780+
<<<<<<< HEAD
16481781
"Axis.units": [
16491782
"doc/api/prev_api_changes/api_changes_2.2.0.rst:77"
1783+
=======
1784+
"GTK3Agg": [
1785+
"doc/api/prev_api_changes/api_changes_2.2.0.rst:285"
1786+
],
1787+
"GTK3Cairo": [
1788+
"doc/api/prev_api_changes/api_changes_2.2.0.rst:285"
1789+
>>>>>>> Add where="between"/"edges" to step and step="between" to fill_between
16501790
],
16511791
"Text.set_text": [
16521792
"doc/api/prev_api_changes/api_changes_3.0.0.rst:64",
@@ -3564,11 +3704,23 @@
35643704
"doc/api/prev_api_changes/api_changes_0.98.x.rst:89",
35653705
"doc/tutorials/intermediate/artists.rst:172",
35663706
"doc/tutorials/intermediate/artists.rst:285"
3707+
<<<<<<< HEAD
3708+
=======
3709+
],
3710+
"matplotlib.axes.Axes.axesPatch": [
3711+
"doc/api/prev_api_changes/api_changes_0.98.x.rst:89"
3712+
>>>>>>> Add where="between"/"edges" to step and step="between" to fill_between
35673713
],
35683714
"matplotlib.axes.Axes.patch": [
35693715
"doc/api/prev_api_changes/api_changes_0.98.x.rst:89",
35703716
"doc/tutorials/intermediate/artists.rst:172",
35713717
"doc/tutorials/intermediate/artists.rst:384"
3718+
<<<<<<< HEAD
3719+
=======
3720+
],
3721+
"matplotlib.axes.Axes.axesFrame": [
3722+
"doc/api/prev_api_changes/api_changes_0.98.x.rst:89"
3723+
>>>>>>> Add where="between"/"edges" to step and step="between" to fill_between
35723724
],
35733725
"matplotlib.axes.Axes.frame": [
35743726
"doc/api/prev_api_changes/api_changes_0.98.x.rst:89"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
step() and fill_between() take a new option where/step="between"
2+
-------------------------------------------------------------------
3+
4+
Previously one would need to trick step() and fill_between() to plot
5+
data where x has one point than y, typically when plotting pre-binned
6+
histograms.
7+
8+
step() now takes where="between" for x, y satisfying either
9+
len(x) + 1 = len(y) or len(x) = len(y) + 1. Plotting a step line "between"
10+
specified edges in either direction. Convenience option where="edges" is
11+
added to close the shape. New kwarg bottom is added to add an underlying
12+
offset.
13+
14+
fill_between() now takes step="between" for x, y satisfying
15+
len(x) + 1 = len(y). Plotting fill "between" specified edges.
16+
17+
fill_betweenx() now takes step="between" for x, y satisfying
18+
len(x) = len(y) + 1. Plotting fill "between" specified edges.

examples/lines_bars_and_markers/filled_step.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
22
=========================
3-
Hatch-filled histograms
3+
Filled histograms
44
=========================
55
6-
Hatching capabilities for plotting histograms.
6+
Filled histograms and hatching capabilities for plotting histograms.
77
"""
88

99
import itertools
@@ -15,6 +15,28 @@
1515
import matplotlib.ticker as mticker
1616
from cycler import cycler
1717

18+
###############################################################################
19+
# Plain filled steps
20+
21+
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9, 4.5), tight_layout=True)
22+
ax1.fill_between([0, 1, 2, 3], [1, 2, 3], step='between')
23+
ax2.fill_betweenx([0, 1, 2, 3], [0, 1, 2], step='between')
24+
ax1.set_ylabel('counts')
25+
ax1.set_xlabel('edges')
26+
ax2.set_xlabel('counts')
27+
ax2.set_ylabel('edges')
28+
29+
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9, 4.5), tight_layout=True)
30+
ax1.fill_between([0, 1, 2, 3], [1, 2, 3], [0, 1, 0], step='between')
31+
ax2.fill_betweenx([0, 1, 2, 3], [1, 2, 3], [0, 1, 0], step='between')
32+
ax1.set_ylabel('counts')
33+
ax1.set_xlabel('edges')
34+
ax2.set_xlabel('counts')
35+
ax2.set_ylabel('edges')
36+
37+
38+
###############################################################################
39+
# Hatches
1840

1941
def filled_hist(ax, edges, values, bottoms=None, orientation='v',
2042
**kwargs):

examples/lines_bars_and_markers/step_demo.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@
2929
plt.legend(title='Parameter where:')
3030
plt.show()
3131

32+
# Plotting with where='between'/'edges'
33+
values = np.array([6, 14, 32, 37, 48, 32, 21, 4]) # hist
34+
edges = np.array([1., 2., 3., 4., 5., 6., 7., 8., 9.]) # bins
35+
bottom = -10
36+
fig, axes = plt.subplots(4, 2)
37+
axes = axes.flatten()
38+
axes[0].step(edges, values, where='between')
39+
axes[1].step(values, edges, where='between')
40+
axes[2].step(edges, values, where='edges')
41+
axes[3].step(values, edges, where='edges')
42+
axes[4].step(edges, values, where='edges', bottom=bottom)
43+
axes[5].step(values, edges, where='edges', bottom=bottom)
44+
axes[6].step(edges, values, where='edges', bottom=bottom)
45+
axes[6].semilogy()
46+
axes[7].step(edges, values, where='edges', bottom=bottom)
47+
axes[7].semilogy()
48+
49+
fig.show()
50+
3251
#############################################################################
3352
#
3453
# ------------

0 commit comments

Comments
 (0)