.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_parula_contours.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end <sphx_glr_download_auto_examples_plot_parula_contours.py>` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_parula_contours.py: Parula colormap example ======================= Demonstrate niceplot's Parula colormap on a simple contour plot .. GENERATED FROM PYTHON SOURCE LINES 6-77 .. image-sg:: /auto_examples/images/sphx_glr_plot_parula_contours_001.svg :alt: plot parula contours :srcset: /auto_examples/images/sphx_glr_plot_parula_contours_001.svg :class: sphx-glr-single-img .. code-block:: Python # ============================================================================== # Standard Python modules # ============================================================================== # ============================================================================== # External Python modules # ============================================================================== import numpy as np from matplotlib import pyplot as plt import niceplots plt.style.use(niceplots.get_style()) colors = niceplots.get_colors() def f(x1, x2): return x1**3 + 2.0 * x1 * x2**2 - x2**3 - 20.0 * x1 x1 = x2 = np.linspace(-5, 5, 201) X1, X2 = np.meshgrid(x1, x2) minimum = [2.58199, 0] q2fig, q2ax = plt.subplots(figsize=(8, 5)) q2ax.contour(X1, X2, f(X1, X2), cmap=niceplots.parula.parula_map, levels=40) q2ax.plot( minimum[0], minimum[1], clip_on=False, marker="o", color=colors["Axis"], markeredgecolor="w", linestyle="", markersize=12, ) q2ax.annotate( "Local Minimum", xy=minimum, xytext=(-5, 10), textcoords="offset points", va="bottom", ha="center", fontsize="small" ) q2ax.plot( -minimum[0], minimum[1], clip_on=False, marker="o", color=colors["Axis"], markeredgecolor="w", linestyle="", markersize=12, ) q2ax.annotate( "Local Maximum", xy=(-minimum[0], 0), xytext=(0, -10), textcoords="offset points", va="top", ha="center", color=colors["Axis"], fontsize="small", ) niceplots.adjust_spines(q2ax, outward=True) q2ax.set_xlabel("$x_1$") q2ax.set_xticks([min(x1), -minimum[0], 0, minimum[0], max(x1)]) q2ax.set_xlim(left=min(x1), right=max(x1)) q2ax.set_ylim(bottom=min(x2), top=max(x2)) q2ax.set_yticks([min(x2), 0, minimum[-1], max(x2)]) q2ax.set_ylabel("$x_2$", rotation="horizontal", ha="right") plt.savefig("parula_contours.png") plt.savefig("parula_contours.svg") niceplots.save_figs(q2fig, "parula_contours", ["png", "svg"]) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.973 seconds) .. _sphx_glr_download_auto_examples_plot_parula_contours.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_parula_contours.ipynb <plot_parula_contours.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_parula_contours.py <plot_parula_contours.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_parula_contours.zip <plot_parula_contours.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_