.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_custom_variable_example.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_auto_examples_plot_custom_variable_example.py: Custom Variable Example =================================== How to add a custom variable to a Data object and plot a histogram of it. .. GENERATED FROM PYTHON SOURCE LINES 8-21 .. image-sg:: /auto_examples/images/sphx_glr_plot_custom_variable_example_001.png :alt: plot custom variable example :srcset: /auto_examples/images/sphx_glr_plot_custom_variable_example_001.png :class: sphx-glr-single-img .. code-block:: Python from gerg_plotting import Data,Variable,Histogram import numpy as np # Init Data object data = Data() # Init pH Variable object pH = Variable(values=np.random.normal(7.7,scale=0.25,size=1000),name='pH') # Add the pH Variable object to the Data object data.add_custom_variable(pH) # Test by plotting a histogram hist = Histogram(data) hist.plot('pH') hist.save('example_plots/custom_variable_example.png',bbox_inches='tight') .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.105 seconds) .. _sphx_glr_download_auto_examples_plot_custom_variable_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_custom_variable_example.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_custom_variable_example.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_custom_variable_example.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_