.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_gallery/plot_example_data.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_gallery_plot_example_data.py: Plot data =========================== This example demonstrates how to display data using plot_imshow from the plot module. .. GENERATED FROM PYTHON SOURCE LINES 7-21 .. code-block:: Python import matplotlib.pyplot as plt from pytopomap.tools import read_tiff from pytopomap.plot import plot_imshow # Load data from a GeoTIFF file (available on github) url = r"https://raw.githubusercontent.com/marcperuz/pytopomap/main/data/h_deposits.tif" x, y, data = read_tiff(url) # Basic imshow usage. axe = plot_imshow(x, y, data) plt.show() .. image-sg:: /auto_gallery/images/sphx_glr_plot_example_data_001.png :alt: plot example data :srcset: /auto_gallery/images/sphx_glr_plot_example_data_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 22-31 Customized display with advanced parameters ------------------------------------------- You can customize the colormap, display range, and value segmentation. Example with: - 'viridis' colormap - Display only values between 20 and 100 - Discrete color intervals .. GENERATED FROM PYTHON SOURCE LINES 31-44 .. code-block:: Python axe = plot_imshow( x, y, data, cmap="viridis", minval=20, maxval=100, cmap_intervals=[20, 40, 60, 80, 100] ) plt.show() .. image-sg:: /auto_gallery/images/sphx_glr_plot_example_data_002.png :alt: plot example data :srcset: /auto_gallery/images/sphx_glr_plot_example_data_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 45-47 You can also display only unique values (e.g., class labels or categories) This enables a discrete colorbar with labeled ticks. .. GENERATED FROM PYTHON SOURCE LINES 47-64 .. code-block:: Python # Simulated categorical values: data_cat = data.copy() data_cat[(data_cat >= 0) & (data_cat < 30)] = 1 data_cat[(data_cat >= 30) & (data_cat < 60)] = 2 data_cat[(data_cat >= 60)] = 3 axe = plot_imshow( x, y, data_cat, cmap="tab10", unique_values=True ) plt.show() .. image-sg:: /auto_gallery/images/sphx_glr_plot_example_data_003.png :alt: plot example data :srcset: /auto_gallery/images/sphx_glr_plot_example_data_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 65-67 You can remove low-magnitude values using `minval_abs` Useful for cleaning noisy data near zero for instance. .. GENERATED FROM PYTHON SOURCE LINES 67-77 .. code-block:: Python axe = plot_imshow( x, y, data, cmap="plasma", minval_abs=10 ) plt.show() .. image-sg:: /auto_gallery/images/sphx_glr_plot_example_data_004.png :alt: plot example data :srcset: /auto_gallery/images/sphx_glr_plot_example_data_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.668 seconds) .. _sphx_glr_download_auto_gallery_plot_example_data.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_example_data.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_example_data.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_example_data.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_