FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Backport PR #29543 on branch v3.10.0-doc (DOC: Minor improvement on broken_barh()) by meeseeksmachine · Pull Request #29548 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
24 changes: 17 additions & 7 deletions galleries/examples/lines_bars_and_markers/broken_barh.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,30 @@

fig, ax = plt.subplots()
# broken_barh(xranges, (ymin, height))
ax.broken_barh(cpu_1, (5.8, 0.4))
ax.broken_barh(cpu_2, (4.8, 0.4))
ax.broken_barh(cpu_3, (3.8, 0.4))
ax.broken_barh(cpu_1, (-0.2, 0.4))
ax.broken_barh(cpu_2, (0.8, 0.4))
ax.broken_barh(cpu_3, (1.8, 0.4))
ax.broken_barh(cpu_4, (2.8, 0.4))
ax.broken_barh(disk, (1.8, 0.4), color="tab:orange")
ax.broken_barh(network, (0.8, 0.4), color="tab:green")
ax.broken_barh(disk, (3.8, 0.4), color="tab:orange")
ax.broken_barh(network, (4.8, 0.4), color="tab:green")
ax.set_xlim(0, 10)
ax.set_yticks([6, 5, 4, 3, 2, 1],
ax.set_yticks(range(6),
labels=["CPU 1", "CPU 2", "CPU 3", "CPU 4", "disk", "network"])
ax.invert_yaxis()
ax.set_title("Resource usage")

plt.show()

# %%
#
# .. admonition:: References
#
# The use of the following functions, methods, classes and modules is shown
# in this example:
#
# - `matplotlib.axes.Axes.broken_barh` / `matplotlib.pyplot.broken_barh`
# - `matplotlib.axes.Axes.invert_yaxis`
# - `matplotlib.axes.Axes.set_yticks`
#
# .. tags::
#
# component: annotation
Expand Down

Back | FazBrowse Home | New Git URL