Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Render Colorbar Issues

$
0
0

@ted.haley wrote:

I’m having issues rendering a color bar when I’m loading various graphs. I am preprocessing some figures and exporting them to JSON. I then read in the JSON file in a callback and output the figure. The problem arises when selecting a new graph in the dropdown; the colorbar does not re-render when loading in the new graph.

The plot renders correctly when changing from a blank graph to a populated graph, but fails to render the colorbar when moving from a populated graph to a populated graph.

@app.callback(Output('corner_plot_figure', 'figure'),
              [Input('em_campaign_dropdown', 'value'),
               Input('radioitems-inline-input', 'value')])
def em_generate_req_corner_plot(pathname, radio):
    if pathname is not None:
        zb_results = os.path.join(os.getcwd(), 'zb-results')
        campaign_results = os.path.join(zb_results, pathname)
        plotly_directory = os.path.join(campaign_results, 'plotly_plots')
        plotly_plots = os.listdir(plotly_directory)

        if radio == 1:
            fig_dir_list = [plot for plot in plotly_plots if plot.endswith("Requested_Parameters_Corner_Plot.json")]
            if len(fig_dir_list) < 1:
                return ""

            figure_dir = os.path.join(plotly_directory, fig_dir_list[0])

            with open(figure_dir) as json_file:
                data = json.load(json_file)

            return data

        else:
            fig_dir_list = [plot for plot in plotly_plots if plot.endswith("Realised_Parameters_Corner_Plot.json")]
            if len(fig_dir_list) < 1:
                return ""

            figure_dir = os.path.join(plotly_directory, fig_dir_list[0])

            with open(figure_dir) as json_file:
                data = json.load(json_file)

            return data
    else:
        return ""

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6271

Latest Images

Trending Articles



Latest Images