You are reading an old version of the documentation (v3.1.1). For the latest version see https://matplotlib.org/stable/gallery/scales/log_bar.html
Version 3.1.2
matplotlib
Fork me on GitHub

Related Topics

Log BarΒΆ

Plotting a bar chart with a logarithmic y-axis.

../../_images/sphx_glr_log_bar_001.png
import matplotlib.pyplot as plt
import numpy as np

data = ((3, 1000), (10, 3), (100, 30), (500, 800), (50, 1))

dim = len(data[0])
w = 0.75
dimw = w / dim

fig, ax = plt.subplots()
x = np.arange(len(data))
for i in range(len(data[0])):
    y = [d[i] for d in data]
    b = ax.bar(x + i * dimw, y, dimw, bottom=0.001)

ax.set_xticks(x + dimw / 2, map(str, x))
ax.set_yscale('log')

ax.set_xlabel('x')
ax.set_ylabel('y')

plt.show()

Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery