.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "plot_types/basic/bar.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. 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_plot_types_basic_bar.py: Bar Plot -------- Below is an example of how to plot a bar plot using EMCPy's plotting method. .. GENERATED FROM PYTHON SOURCE LINES 9-55 .. image-sg:: /plot_types/basic/images/sphx_glr_bar_001.png :alt: Bar Plot :srcset: /plot_types/basic/images/sphx_glr_bar_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from emcpy.plots.plots import BarPlot from emcpy.plots.create_plots import CreatePlot, CreateFigure def main(): # Create bar plot # Grab sample bar plot data x_pos, heights = _getBarData() # Create bar plot object bar = BarPlot(x_pos, heights) bar.color = 'tab:red' # Create plot object and add features plot1 = CreatePlot() plot1.plot_layers = [bar] plot1.add_xlabel(xlabel='X Axis Label') plot1.add_ylabel(ylabel='Y Axis Label') plot1.add_title("Bar Plot") # Create figure fig = CreateFigure() fig.plot_list = [plot1] fig.create_figure() plt.show() def _getBarData(): # Generate test data for bar graphs x = ['a', 'b', 'c', 'd', 'e', 'f'] heights = [5, 6, 15, 22, 24, 8] x_pos = [i for i, _ in enumerate(x)] return x_pos, heights if __name__ == '__main__': main() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.054 seconds) .. _sphx_glr_download_plot_types_basic_bar.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: bar.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: bar.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_