.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/scales/log_bar.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. meta:: :keywords: codex .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_scales_log_bar.py: ======= Log Bar ======= Plotting a bar chart with a logarithmic y-axis. .. GENERATED FROM PYTHON SOURCE LINES 8-30 .. image-sg:: /gallery/scales/images/sphx_glr_log_bar_001.png :alt: log bar :srcset: /gallery/scales/images/sphx_glr_log_bar_001.png, /gallery/scales/images/sphx_glr_log_bar_001_2_00x.png 2.00x :class: sphx-glr-single-img .. code-block:: Python 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, labels=map(str, x)) ax.set_yscale('log') ax.set_xlabel('x') ax.set_ylabel('y') plt.show() .. _sphx_glr_download_gallery_scales_log_bar.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: log_bar.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: log_bar.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_