.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_subplots_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_subplots_example.py: Subplots Example =================================== Example of how to create subplots. .. GENERATED FROM PYTHON SOURCE LINES 8-48 .. image-sg:: /auto_examples/images/sphx_glr_plot_subplots_example_001.png :alt: Surface Layer Properties (0-5 Meters), Bathymetry on and Coastlines on, Bathymetry on and Coastlines off, Bathymetry off and Coastlines on, Bathymetry off and Coastlines off, Bathymetry off, Coastlines off, and Grid off, Bathymetry off, Coastlines off, Grid off, Coordinates off :srcset: /auto_examples/images/sphx_glr_plot_subplots_example_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/gerg-plotting/envs/latest/lib/python3.12/site-packages/cartopy/io/__init__.py:241: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/10m_physical/ne_10m_coastline.zip warnings.warn(f'Downloading: {url}', DownloadWarning) | .. code-block:: Python from gerg_plotting import MapPlot, Bounds,Variable, data_from_df import matplotlib.pyplot as plt import cartopy.crs as ccrs import pandas as pd # Define bounds bounds = Bounds(lat_min = 24,lat_max = 31,lon_min = -99, lon_max = -88, depth_top=-1, depth_bottom=500, vertical_scalar=1/1000,vertical_units='km') # Let's read in the example data df = pd.read_csv('example_data/sample_glider_data.csv') # Select the top 5 meters of the data df = df[df.pressure<5] # Init the data object with the bounds data = data_from_df(df,bounds=bounds) # Add a custom variable data.add_custom_variable(variable=Variable(values=df['Turner_angle'],name='Turner_angle',label='Turner Angle (°)')) # Init subplots fig,ax = plt.subplots(figsize=(10,24),nrows=6,subplot_kw={'projection': ccrs.PlateCarree()},layout='constrained') pointsize = 25 # Init MapPlot object plotter = MapPlot(data=data,grid_spacing=3) # Generate Scatter plots on one figure plotter.scatter(fig=fig,ax=ax[0],var='temperature',show_bathy=True,pointsize=pointsize) plotter.ax.set_title('Bathymetry on and Coastlines on') plotter.scatter(fig=fig,ax=ax[1],var='salinity',show_bathy=True,show_coastlines=False,pointsize=pointsize) plotter.ax.set_title('Bathymetry on and Coastlines off') plotter.scatter(fig=fig,ax=ax[2],var='depth',show_bathy=False,show_coastlines=True,pointsize=pointsize) plotter.ax.set_title('Bathymetry off and Coastlines on') plotter.scatter(fig=fig,ax=ax[3],var='density',show_bathy=False,show_coastlines=False,pointsize=pointsize) plotter.ax.set_title('Bathymetry off and Coastlines off') plotter.scatter(fig=fig,ax=ax[4],var='Turner_angle',show_bathy=False,show_coastlines=False,grid=False,pointsize=pointsize) plotter.ax.set_title('Bathymetry off, Coastlines off, and Grid off') plotter.scatter(fig=fig,ax=ax[5],var='time',show_bathy=False,show_coastlines=False,grid=False,show_coords=False,pointsize=pointsize) plotter.ax.set_title('Bathymetry off, Coastlines off, Grid off, Coordinates off') # Add a title plotter.fig.suptitle('Surface Layer Properties (0-5 Meters)',fontsize = 20) # If you want to show the plot # plotter.show() plotter.save('example_plots/map_subplots_example.png',dpi=500,bbox_inches='tight') .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 4.921 seconds) .. _sphx_glr_download_auto_examples_plot_subplots_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_subplots_example.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_subplots_example.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_subplots_example.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_