.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples\visualization\plot_graphics_antibiogram.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__examples_visualization_plot_graphics_antibiogram.py: Graphics Antibiogram example ============================ .. GENERATED FROM PYTHON SOURCE LINES 5-87 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /_examples/visualization/images/sphx_glr_plot_graphics_antibiogram_001.png :alt: Antibiogram (euclidean, weighted) :srcset: /_examples/visualization/images/sphx_glr_plot_graphics_antibiogram_001.png :class: sphx-glr-multi-img * .. image-sg:: /_examples/visualization/images/sphx_glr_plot_graphics_antibiogram_002.png :alt: Antibiogram (euclidean, weighted) :srcset: /_examples/visualization/images/sphx_glr_plot_graphics_antibiogram_002.png :class: sphx-glr-multi-img .. code-block:: default :lineno-start: 6 # Libraries from __future__ import division # Libraries import sys import numpy as np import pandas as pd import seaborn as sns import matplotlib as mpl import matplotlib.pyplot as plt # from pyamr.graphics.antibiogram import Antibiogram # Configure seaborn style (context=talk) sns.set(style="white") # Set matplotlib mpl.rcParams['xtick.labelsize'] = 9 mpl.rcParams['ytick.labelsize'] = 9 mpl.rcParams['axes.titlesize'] = 11 mpl.rcParams['legend.fontsize'] = 9 # Pandas configuration pd.set_option('display.max_colwidth', 40) pd.set_option('display.width', 300) pd.set_option('display.precision', 4) # Numpy configuration np.set_printoptions(precision=2) # ------------------------------------------------------------------------- # helper methods # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- # main # ------------------------------------------------------------------------- # Data path. path = '../../pyamr/fixtures/fixture_antibiogram.csv' # ------------------------------- # Load data # ------------------------------- # Load dataframe = pd.read_csv(path) # ------------------------------- # Create object # ------------------------------- # Antibiogram plotter antibiogram = Antibiogram(column_organism='organismCode', column_antibiotic='antibioticCode', column_genus='specieName', column_category='antibioticClass', column_index='sari') # Fit antibiogram antibiogram = antibiogram.fit(dataframe) # --------- # Example 1 # ---------- antibiogram.plot(organisms=['ECOL', 'SAUR'], figsize=(15, 3)) # --------- # Example 2 # --------- antibiogram.plot(genera=['staphylococcus', 'klebsiella', 'streptococcus', 'enterococcus', 'enterobacter'], categories=None, method='weighted', metric='euclidean', figsize=(16, 9)) # Show plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 2.109 seconds) .. _sphx_glr_download__examples_visualization_plot_graphics_antibiogram.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_graphics_antibiogram.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_graphics_antibiogram.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_