PlotlyHelper – Reference

Source code

Class PlotlyHelper

    To assist in the use of the plotly library
    
nameargumentsreturns
get_default_colorscls, n :int[int]
        Return a list of n colors, specified by their standard plotly names;
        meant for situations when 1 or more default colors are needed.

        The choice of default colors is hardwired in this function.

        :param n:   Desired number of default colors
        :return:
        
nameargumentsreturns
plot_curvescls, x, y, title="", xrange=None, xlabel="", ylabel="", curve_labels=None, legend_title=None, colors=None, show=Falsepgo.Figure
        Plot one or more 2D curves

        :param x:           A Numpy array, with the (common) x-axis values
        :param y:           Either a Numpy array, or a list/tuple of them, with the y-axis values of the curve(s)
        :param title:       (OPTIONAL) Title to use for the overall plot
        :param xrange:      (OPTIONAL) list of the form [t_start, t_end], to initially only show a part of the timeline.
                                Note: it's still possible to zoom out, and see the excluded portion
        :param xlabel:      (OPTIONAL) Caption to use for the x-axis
        :param ylabel:      (OPTIONAL) Caption to use for the y-axis
        :param curve_labels:(OPTIONAL) String, or list of strings.
                                Label(s) to use for the various curves in the legend and in the hover boxes.
                                If missing, and there's only 1 curve, the legend box won't be shown
        :param legend_title:(OPTIONAL) String to show at the top of the legend box.
                                Ignored if curve_labels wasn't set.
                                If not provided, and the legend box is shown, it will appear as "variable"
        :param colors:      (OPTIONAL) Either a single color (string with standard plotly name, such as "red"),
                                or list of names to use, in order; if None, then use the hardwired defaults
        :param show:        If True, the plot will be shown
                                Note: in JupyterLab, simply returning a plot object (without assigning it to a variable)
                                leads to it being automatically shown

        :return:            A plotly "Figure" object
        
nameargumentsreturns
combine_plotscls, fig_list :Union[list, tuple], title="", xlabel=None, ylabel=None, xrange=None, curve_labels=None, legend_title=None, show=Falsepgo.Figure
        Combine together several existing plotly plots

        :param fig_list:    List or tuple of plotly "Figure" objects (as returned by several functions)
        :param title:       (OPTIONAL) The title to use for the overall plot
        :param xlabel:      (OPTIONAL) Caption to use for the x-axis; if not specified, use that of the 1st plot
        :param ylabel:      (OPTIONAL) Caption to use for the y-axis; if not specified, use that of the 1st plot
        :param xrange:      (OPTIONAL) list of the form [t_start, t_end], to initially only show a part of the timeline.
                                Note: it's still possible to zoom out, and see the excluded portion
        :param curve_labels:(OPTIONAL) List of labels to use for the various curves in the legend
                                and in the hover boxes; if not specified, use the titles of the individual plots
        :param legend_title:(OPTIONAL) String to show at the top of the legend box
        :param show:        If True, the plot will be shown
                                Note: on JupyterLab, simply returning a plot object (without assigning it to a variable)
                                      leads to it being automatically shown
        :return:            A plotly "Figure" object for the combined plot