.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/indiv_funcs/test_colormatch.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_indiv_funcs_test_colormatch.py: show an easy method for matching colors using pyspecdata .. GENERATED FROM PYTHON SOURCE LINES 2-29 .. image-sg:: /auto_examples/indiv_funcs/images/sphx_glr_test_colormatch_001.png :alt: test colormatch :srcset: /auto_examples/indiv_funcs/images/sphx_glr_test_colormatch_001.png, /auto_examples/indiv_funcs/images/sphx_glr_test_colormatch_001_2_00x.png 2.00x :class: sphx-glr-single-img .. code-block:: Python import pyspecdata as psd import matplotlib.pylab as plt from numpy import r_ # when we set the plot color, it overrides any defaults a = psd.nddata(r_[0:9], "t", alpha=0.5) # after we do this, we no longer need to specify the color argument to plot -- # it's a property of the data. It chooses the next color in the default matplotlib cycle a.set_plot_color_next() # If you want to give a specific color, note that the above is equivalent to # a.set_plot_color(psd.mpl_utils.default_cycler) psd.plot(a) # as long as we don't override that property, # it will continue to be used b = a + 10 psd.plot(b, alpha=0.2) # and if we copy our properties, this gets copied as one of them c = psd.nddata(r_[0:9] + 0.1, "t", alpha=0.2) c.copy_props(a) psd.plot(c, ".") d = psd.nddata(r_[0:9] + 0.2, "t", alpha=0.2) d += 0.1 # but wait! what if I have an unrelated set of data, but still want to move to # the next color in the default matplotlib cycle? just do this: d.set_plot_color_next() psd.plot(d, ":", alpha=0.5) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.229 seconds) .. _sphx_glr_download_auto_examples_indiv_funcs_test_colormatch.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: test_colormatch.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: test_colormatch.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_