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

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions galleries/examples/lines_bars_and_markers/broken_barh.py
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