.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "source/auto_examples/plotting/plot_secondary_y.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_source_auto_examples_plotting_plot_secondary_y.py: Secondary Y-Axis Plotting ------------------------- This example shows how to plot on the secondary y-axis using Matplotlib functionality. The secondary_y functionality has been removed from ACT. .. GENERATED FROM PYTHON SOURCE LINES 9-41 .. image-sg:: /source/auto_examples/plotting/images/sphx_glr_plot_secondary_y_001.png :alt: sgpmetE13.b1 temp_mean on 20190101 :srcset: /source/auto_examples/plotting/images/sphx_glr_plot_secondary_y_001.png :class: sphx-glr-single-img .. code-block:: Python from arm_test_data import DATASETS import matplotlib.pyplot as plt import act # Read in the data from a MET file filename_met = DATASETS.fetch('sgpmetE13.b1.20190101.000000.cdf') ds = act.io.arm.read_arm_netcdf(filename_met) # Plot temperature and relative humidity with RH on the right axis display = act.plotting.TimeSeriesDisplay(ds, figsize=(10, 6)) # Plot the data and make the y-axes color match the lines display.plot('temp_mean', match_line_label_color=True) display.day_night_background() # Get the secondary y-axes and plot the RH on it ax2 = display.axes[0].twinx() ax2.plot(ds['time'], ds['rh_mean'], color='orange') # Then the axes can be updated and modified through the normal matplotlib calls. display.axes[0].set_yticks([-5, 0, 5]) display.axes[0].set_yticklabels(["That's cold", "Freezing", "Above Freezing"]) # Secondary y-axis will use the ax2 axes ax2.set_yticks([65, 75, 85]) ax2.set_yticklabels(['Not as humid', 'Slightly Humid', 'Humid']) ax2.set_ylabel('Relative Humidity (%)', color='orange') plt.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.228 seconds) .. _sphx_glr_download_source_auto_examples_plotting_plot_secondary_y.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_secondary_y.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_secondary_y.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_secondary_y.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_