How to use the plotly.tools.make_subplots function in plotly

To help you get started, we’ve selected a few plotly examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Haschtl / RealTimeOpenControl / RTOC / RTLogger / RTOC_Web_standalone.py View on Github external
sig = signals
        lastSignals = signals
    else:
        sig = lastSignals
    for signal in sig:
        if signal[2] in selection:
            if signal[3] not in sorted.keys():
                sorted[signal[3]] = []
            sorted[signal[3]].append(signal[0:3])
    # Create the graph with subplots
    if len(sorted) == 0:
        greater1 = 1
    else:
        greater1 = len(sorted)
    # subplot_titles=tuple(sorted.keys()))
    fig = plotly.tools.make_subplots(rows=greater1, cols=1, vertical_spacing=0.2,)
    fig['layout']['margin'] = {
        'l': 30, 'r': 10, 'b': 30, 't': 10
    }
    fig['layout']['legend'] = {'x': 0, 'y': 1, 'xanchor': 'left'}
    # print(sorted)

    for idx, unit in enumerate(sorted.keys()):
        #fig['layout']['xaxis'+str(idx+1)]['tickformat'] = '%H:%M:%S %d.%m.%Y'
        for signal in sorted[unit]:
            fig.append_trace({
                'x': signal[0],
                'y': signal[1],
                'name': signal[2]+' ['+unit+']',
                'mode': 'lines+markers',
                'type': 'scatter'
            }, idx+1, 1)
github vitchyr / viskit / viskit / frontend.py View on Github external
):
    """
    plot_lists is a list of lists.
    Each outer list represents different y-axis attributes.
    Each inner list represents different experiments to run, within that y-axis
    attribute.
    Each plot is an AttrDict which should have the elements used below.
    """

    x_axis = [(subplot['plot_key'], subplot['means']) for plot_list in plot_lists for subplot in plot_list if subplot['x_key']]
    plot_lists = [[subplot for subplot in plot_list] for plot_list in plot_lists if not plot_list[0]['x_key']]
    xlabel = x_axis[0][0] if len(x_axis) else 'iteration'

    p25, p50, p75 = [], [], []
    num_y_axes = len(plot_lists)
    fig = tools.make_subplots(rows=num_y_axes, cols=1, print_grid=False)
    fig['layout'].update(
        width=plot_width,
        height=plot_height,
        title=title,
    )

    for y_idx, plot_list in enumerate(plot_lists):
        for idx, plt in enumerate(plot_list):
            color = core.color_defaults[idx % len(core.color_defaults)]
            if use_median:
                p25.append(np.mean(plt.percentile25))
                p50.append(np.mean(plt.percentile50))
                p75.append(np.mean(plt.percentile75))
                if x_axis:
                    x = list(x_axis[idx][1])
                else:
github kengz / SLM-Lab / slm_lab / lib / viz.py View on Github external
def plot_experiment(experiment_spec, experiment_df, metrics_cols):
    '''
    Plot the metrics vs. specs parameters of an experiment, where each point is a trial.
    ref colors: https://plot.ly/python/heatmaps-contours-and-2dhistograms-tutorial/#plotlys-predefined-color-scales
    '''
    y_cols = metrics_cols
    x_cols = ps.difference(experiment_df.columns.tolist(), y_cols + ['trial'])
    fig = tools.make_subplots(rows=len(y_cols), cols=len(x_cols), shared_xaxes=True, shared_yaxes=True, print_grid=False)
    strength_sr = experiment_df['strength']
    min_strength, max_strength = strength_sr.min(), strength_sr.max()
    for row_idx, y in enumerate(y_cols):
        for col_idx, x in enumerate(x_cols):
            x_sr = experiment_df[x]
            guard_cat_x = x_sr.astype(str) if x_sr.dtype == 'object' else x_sr
            trace = go.Scatter(
                y=experiment_df[y], yaxis=f'y{row_idx+1}',
                x=guard_cat_x, xaxis=f'x{col_idx+1}',
                showlegend=False, mode='markers',
                marker={
                    'symbol': 'circle-open-dot', 'color': strength_sr, 'opacity': 0.5,
                    # dump first portion of colorscale that is too bright
                    'cmin': min_strength - 0.5 * (max_strength - min_strength), 'cmax': max_strength,
                    'colorscale': 'YlGnBu', 'reversescale': True
                },
github shwang / pedestrian_prediction / plot.py View on Github external
return occupancies.reshape(g.rows, g.cols)

    for i in xrange(len(trajectory)):
        if i == 0:
            traj = [(start, Actions.ABSORB)]
        else:
            traj = trajectory[:i]

        fixed_occupancies = format_occ(infer_occupancies(g, traj, beta=beta_fixed,
                dest_set=set([model_goal])))
        data1 = output_heat_map(g, fixed_occupancies, traj, start,
                dest_set=set([model_goal]),
                auto_logarithm=auto_log,
                zmin=zmin, zmax=zmax)

        fig = tools.make_subplots(rows=1, cols=1,
                subplot_titles=(
                    "beta={} (Ziebart beta)".format(beta_fixed),))
        fig['layout'].update(
                title=("Correct Goal, movement reward={R}, " +
                "{min_beta}&lt;beta&lt;{max_beta}<br>t={t}").format(
                    t=i, R=R, min_beta=min_beta, max_beta=max_beta))

        for t in data1:
            fig.append_trace(t, 1, 1)
        # py.plot(fig, filename=u"output/{}.html".format(100+i))
        py.plot(fig, filename=u"output/{}.html".format(100+i),
            image=u'png', image_filename=u"output/{}.png".format(100+i),
            image_width=1400, image_height=750)
github SheffieldML / GPy / GPy / plotting / plotly_dep / plot_definitions.py View on Github external
def figure(self, rows=1, cols=1, specs=None, is_3d=False, **kwargs):
        if specs is None:
            specs = [[{'is_3d': is_3d}]*cols]*rows
        figure = tools.make_subplots(rows, cols, specs=specs, **kwargs)
        return figure
github photon-team / photon / Framework / ResultLogging.py View on Github external
def plot_config_performances_for_outer_fold(self, outer_cv_fold=0, output_filename=''):
        if not output_filename:
            output_filename = 'PHOTON_Results_' + self.name + '_' + datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        tested_configs = self.get_tested_configurations_for(outer_cv_fold=outer_cv_fold)

        tracelist = []

        col_nr = 4
        row_nr = int(np.ceil(len(tested_configs) / col_nr))

        fig = tools.make_subplots(row_nr, col_nr, shared_xaxes=True, shared_yaxes=True,
                                  subplot_titles=[item.pretty_config_dict() for item in tested_configs])

        col_cnt = 1
        row_cnt = 1

        for cfg in tested_configs:
            inner_fold_list = cfg.fold_list
            cnt = 0
            metric_list = []
            name_list = []
            text_list = []
            for fold in inner_fold_list:
                for metric_name, metric_value in fold.train.metrics.items():
                    metric_list.append(metric_value)
                    name_list.append(metric_name)
                    text_list.append('inner fold ' + str(cnt + 1))
github tyiannak / multimodalAnalysis / audio / example10.py View on Github external
from pyAudioAnalysis import ShortTermFeatures as aF
from pyAudioAnalysis import audioBasicIO as aIO


if __name__ == '__main__':
    win = 0.05
    fp1 = "../data/general/speech/m1_neu-m1-l1.wav.wav" # male
    fp2 = "../data/general/speech/f1_neu-f1-l2.wav.wav" # female
    # read machine sound
    fs1, s1 = aIO.read_audio_file(fp1)
    fs2, s2 = aIO.read_audio_file(fp2)
    dur1, dur2 = len(s1) / float(fs1), len(s2) / float(fs2)
    # extract short term features
    [f1, fn] = aF.feature_extraction(s1, fs1, int(fs1 * win), int(fs1 * win))
    [f2, fn] = aF.feature_extraction(s2, fs2, int(fs2 * win), int(fs2 * win))
    figs = plotly.tools.make_subplots(rows=1, cols=2,
                                      subplot_titles=[fn[9], fn[10]])
    t1 = np.arange(0, dur1 - 0.050, 0.050)
    t2 = np.arange(0, dur2 - 0.050, 0.050)
    figs.append_trace(go.Scatter(x=t1, y=f1[9, :], name="male"), 1, 1)
    figs.append_trace(go.Scatter(x=t2, y=f2[9, :], name="female"), 1, 1)
    figs.append_trace(go.Scatter(x=t1, y=f1[10, :], name="male"), 1, 2)
    figs.append_trace(go.Scatter(x=t2, y=f2[10, :], name="female"), 1, 2)

    plotly.offline.plot(figs, filename="temp.html", auto_open=True)
github pymzml / pymzML / pymzml / plot_revised.py View on Github external
def save(self, filename=None, xLimits=None):
        """
        Saves all plots and their data points that have been added to the
        plotFactory.

        Args:
        filename (str): Name for the output file. Default = "spectrum_plot.html"
        mz_range (tuple): m/z range which should be considered [start, end].
            Default = None
        """
        plot_number = len(self.plots)

        rows, cols = int(math.ceil(plot_number / float(2))), 2

        if plot_number % 2 == 0:
            my_figure = tools.make_subplots(
                rows=rows, cols=cols, vertical_spacing=0.6 / rows
            )
        else:
            specs = [[{}, {}] for x in range(rows - 1)]
            specs.append([{'colspan': 2}, None])
            my_figure = tools.make_subplots(
                rows=rows,
                cols=cols,
                vertical_spacing=0.6 / rows,
                specs=specs,
                subplot_titles=self.titles
            )

        for i, plot in enumerate(self.plots):
            for j, trace in enumerate(plot):
                my_figure.append_trace(
github shwang / pedestrian_prediction / study_traj.py View on Github external
o1 = infer_occupancies(g, traj, beta=beta1,
        dest_set={goal}).reshape(g.rows, g.cols)
    data1 = output_heat_map(g, o1, traj, start, {goal}, beta_hat=beta1, zmin=-10)

    o2 = infer_occupancies(g, traj, beta=beta2,
        dest_set={goal}).reshape(g.rows, g.cols)
    data2 = output_heat_map(g, o2, traj, start, {goal}, beta_hat=beta2, zmin=-10)

    o_diff = np.abs(o1 - o2)
    data3 = output_heat_map(g, o_diff, traj, start, {goal}, beta_hat=beta1, zmin=-10)

    import plotly.offline as py
    import plotly.graph_objs as go
    from plotly import offline
    from plotly import tools as tools
    fig = tools.make_subplots(rows=1, cols=3,
            subplot_titles=(
                "expected occupancies, beta={}".format(beta1),
                "expected occupancies, beta={}".format(beta2),
                "abs difference in ex. occupancies"))
    fig['layout'].update(title=title)

    for t in data1:
        fig.append_trace(t, 1, 1)
    for t in data2:
        fig.append_trace(t, 1, 2)
    for t in data3:
        fig.append_trace(t, 1, 3)
    # py.plot(fig, filename="output/beta_versus.html")
    py.plot(fig, filename="output/beta_versus_{}.html".format(100+uid),
            image='png', image_filename="output/beta_versus_{}.png".format(100+uid),
            image_width=1400, image_height=750)