

.. _sphx_glr_gallery_scales_log_bar.py:


=======
Log Bar
=======

Plotting a bar chart with a logarithmic y-axis.




.. image:: /gallery/scales/images/sphx_glr_log_bar_001.png
    :align: center





.. 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, map(str, x))
    ax.set_yscale('log')

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

    plt.show()

**Total running time of the script:** ( 0 minutes  0.070 seconds)



.. only :: html

 .. container:: sphx-glr-footer


  .. container:: sphx-glr-download

     :download:`Download Python source code: log_bar.py <log_bar.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: log_bar.ipynb <log_bar.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
