• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

spedas / pyspedas / 16929898973

13 Aug 2025 06:52AM UTC coverage: 89.515% (+0.4%) from 89.086%
16929898973

push

github

jameswilburlewis
Fixing a few missing 'projects.mission' references

18 of 19 new or added lines in 4 files covered. (94.74%)

132 existing lines in 10 files now uncovered.

40006 of 44692 relevant lines covered (89.51%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/pyspedas/pytplot/tplot.py
1
# Copyright 2018 Regents of the University of Colorado. All Rights Reserved.
2
# Released under the MIT license.
3
# This software was developed at the University of Colorado's Laboratory for Atmospheric and Space Physics.
4
# Verify current version before use at: https://github.com/MAVENSDC/PyTplot
5

6
import sys
1✔
7
import os
1✔
8
import logging
1✔
9
import pyspedas
1✔
10
import tempfile
1✔
11
from .MPLPlotter.tplot import tplot as mpl_tplot
1✔
12

13

14
using_graphics = False  # there doesn't seem to be an execution path that make this true
1✔
15

16
def tplot(name,
1✔
17
          trange=None,
18
          var_label=None,
19
          slice=False,
20
          combine_axes=True,
21
          nb=False,
22
          save_file=None,
23
          gui=False,
24
          qt=False,
25
          bokeh=False,
26
          save_png=None,
27
          display=True,
28
          testing=False,
29
          extra_functions=[],
30
          extra_function_args=[],
31
          vert_spacing=None,
32
          pos_2d=False,
33
          pos_3d=False,
34
          exec_qt=True,
35
          window_name='Plot',
36
          interactive=False,
37
          # the following are for the matplotlib version
38
          xsize=None,
39
          ysize=None,
40
          save_eps='', 
41
          save_svg='', 
42
          save_pdf='',
43
          save_jpeg='',
44
          dpi=None,
45
          fig=None, 
46
          axis=None, 
47
          pseudo_plot_num=None, 
48
          second_axis_size=0.0,
49
          return_plot_objects=False):
50
    """
51
    This is the function used to display the tplot variables stored in memory.  It is a wrapper that
52
    calls a matplotlib-specific version of tplot.
53

54
    Parameters
55
    ----------
56
        name : str or list of str, required
57
            List of tplot variables that will be plotted.
58
            If this is empty, nothing will be plotted.
59
        trange: list of string or float, optional
60
            If set, this time range will be used, temporarily overriding any previous xlim or timespan calls
61
        var_label : str, optional
62
            The name of the tplot variable you would like as
63
            a second x axis.
64
        xsize: float, optional
65
            Plot size in the horizontal direction (in inches)
66
        ysize: float, optional
67
            Plot size in the vertical direction (in inches)
68
        dpi: float, optional
69
            The resolution of the plot in dots per inch
70
        save_png : str, optional
71
            A full file name and path.
72
            If this option is set, the plot will be automatically saved to the file name provided in a PNG format.
73
        save_eps : str, optional
74
            A full file name and path.
75
            If this option is set, the plot will be automatically saved to the file name provided in a EPS format.
76
        save_jpeg : str, optional
77
            A full file name and path.
78
            If this option is set, the plot will be automatically saved to the file name provided in a JPEG format.
79
        save_pdf : str, optional
80
            A full file name and path.
81
            If this option is set, the plot will be automatically saved to the file name provided in a PDF format.
82
        save_svg : str, optional
83
            A full file name and path.
84
            If this option is set, the plot will be automatically saved to the file name provided in a SVG format.
85
        display: bool, optional
86
            If True, then this function will display the plotted tplot variables. Necessary to make this optional
87
            so we can avoid it in a headless server environment.
88
        return_plot_objects: bool, optional
89
            If true, returns the matplotlib fig and axes objects for further manipulation.
90

91
    Returns
92
    -------
93
        Any
94
            Returns matplotlib fig and axes objects, if return_plot_objects==True
95

96
    Examples
97
    --------
98
        >>> #Plot a single line in bokeh
99
        >>> import pyspedas
100
        >>> x_data = [2,3,4,5,6]
101
        >>> y_data = [1,2,3,4,5]
102
        >>> pyspedas.store_data("Variable1", data={'x':x_data, 'y':y_data})
103
        >>> pyspedas.tplot("Variable1",bokeh=True)
104

105
        >>> #Display two plots
106
        >>> x_data = [1,2,3,4,5]
107
        >>> y_data = [[1,5],[2,4],[3,3],[4,2],[5,1]]
108
        >>> pyspedas.store_data("Variable2", data={'x':x_data, 'y':y_data})
109
        >>> pyspedas.tplot(["Variable1", "Variable2"])
110

111
        >>> #Display 2 plots, using Variable1 as another x axis
112
        >>> x_data = [1,2,3]
113
        >>> y_data = [ [1,2,3] , [4,5,6], [7,8,9] ]
114
        >>> v_data = [1,2,3]
115
        >>> pyspedas.store_data("Variable3", data={'x':x_data, 'y':y_data, 'v':v_data})
116
        >>> pyspedas.options("Variable3", 'spec', 1)
117
        >>> pyspedas.tplot(["Variable2", "Variable3"], var_label='Variable1')
118

119
    """
120
    # If no tplot names were provided, exit
121
    if name is None or len(name) < 1:
1✔
UNCOV
122
        logging.error("no valid tplot variables were provided.")
×
UNCOV
123
        return
×
124
    elif not isinstance(name, list):
1✔
125
        name = [name] # If only one name was provided, put it in a list
1✔
126
    num_plots = len(name)
1✔
127

128
    if qt == False and bokeh == False:
1✔
129
        return mpl_tplot(name,
1✔
130
                         trange=trange,
131
                         var_label=var_label,
132
                         xsize=xsize,
133
                         ysize=ysize,
134
                         save_png=save_png,
135
                         save_eps=save_eps,
136
                         save_svg=save_svg,
137
                         save_pdf=save_pdf,
138
                         save_jpeg=save_jpeg,
139
                         dpi=dpi,
140
                         display=display,
141
                         fig=fig,
142
                         axis=axis,
143
                         slice=slice,
144
                         running_trace_count=pseudo_plot_num,
145
                         second_axis_size=second_axis_size,
146
                         return_plot_objects=return_plot_objects)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc