2

I'm using the Parallel Coordinates Plot from Plotly graph_object (by using their tutorial) but I cannot seem to get the left and right hand side axis labels to not be cut off: enter image description here

Here is my code for the layout:

   """ Define app layout """
app.layout = html.Div([
    dbc.Container([
        # Header
        dbc.Row([
            dbc.Col(
                html.Div(                       
                    html.H4(children="Dashboard")
                ),
            ),
        ]),
        dbc.Row([
            dbc.Col(
                html.Div([
                    dcc.Graph(id="parallel-coordinates-plot",
                              figure={
                                  "layout": go.Layout(title="Parallel Coordinates Plot"),
                              }),
                    dcc.Dropdown(id="my-dropdown", style={'margin': 15}),
                ]),
            ),
        ]),
    ], fluid=True)
])

And for my callback and function:

    @app.callback(
    Output("parallel-coordinates-plot", "figure"),
    [Input("my-dropdown", "value")])
def update_parallel_coordinates_plot(rex_df):
    rex_df = pd.read_csv("df.csv")
    df = rex_df.copy()

    df_reg = df.loc[:, ["B", "G", "R"]]

    max_values = df_reg.max()
    min_values = df_reg.min()
    print("max_values: ", max_values)
    print("min_values: ", min_values)

    ylimits = (df_reg.min().min(), df_reg.max().max())
    print("ylimits: ", ylimits)
    print("ylimits: ", ylimits[0], ylimits[1])

    fig = go.Figure(data=go.Parcoords(
        line=dict(color=df['y_pred'],
                  showscale=False,
                  ),
        dimensions=list([
            dict(range=[ylimits[0], ylimits[1]],
                 label='B', values=df['B_shap']),
            dict(range=[ylimits[0], ylimits[1]],
                 label='G', values=df['G_shap']),
            dict(range=[ylimits[0], ylimits[1]],
                 label='R', values=df['R_shap']),
        ]),

    ))

    return fig
Penguines
  • 53
  • 3
  • Margins for `plotly` graphs can be set as follows, please refer to the settings from the [official reference](https://plotly.com/python/setting-graph-size/#adjusting-graph-size-with-dash). – r-beginners Mar 27 '22 at 11:05

0 Answers0