MAVENSDC / PyTplot

A python version of the IDL tplot libraries
MIT License
28 stars 17 forks source link

Overplotting curves on a spectrum #150

Closed Stratuholic closed 2 months ago

Stratuholic commented 3 years ago

It seems not possible to overplot curves on a spectrum with pytplot. If so, developing such a feature may be helpful. I need it badly.

Thanks.

jameswilburlewis commented 2 months ago

This has been available for quite a while now in recent versions of pytplot-mpl-temp (the version included in pyspedas, built from the matplotlib-backend branch of this repo). There's an example in pyspedas/utilities/tests/plot_tests.py:

    def test_pseudo_spectra_plus_line(self):
        del_data("*")
        import pyspedas
        pyspedas.mms.fpi(datatype='des-moms', trange=['2015-10-16', '2015-10-17'])
        pyspedas.mms.edp(trange=['2015-10-16', '2015-10-17'], datatype='scpot')
        # Create a pseudovariable with an energy spectrum plus a line plot of spacecraft potential
        store_data('spec', data=['mms1_des_energyspectr_omni_fast', 'mms1_edp_scpot_fast_l2', 'mms1_edp_scpot_fast_l2'])
        # Set some options so that the spectrum, trace, and y axes are legible
        options('mms1_edp_scpot_fast_l2', 'yrange', [10, 100])
        #options('mms2_edp_scpot_fast_l2', 'right_axis', True)
        options('spec','right_axis','True')
        tplot_options('xmargin', [0.1, 0.2])
        timespan('2015-10-16',1,'days')
        tplot_options('title', 'Pseudovar with energy spectrum plus line plot of s/c potential')
        tplot('spec', xsize=12, display=global_display,save_png='MMS_pseudo_spec_plus_line')
        tplot_options('title', '')
        timespan('2007-03-23',1,'days') # Reset to avoid interfering with other tests