Set the size of the plot, Plotly React

610 Views Asked by At

Is it possible to set the width of the graph and the width of the legend separately?

Because "width" in the layout set the width for all plot.

I want to have the next behavior, graph always has the 80% of width and legend the rest 20%. enter image description here

2

There are 2 best solutions below

2
On

The Plotly layout docs give many different options for customizing the layout of your graph.

// entrywidth is a fraction, so 0.2 would be 20%. entrywidthmode specifies that entrywidth is a fraction, not pixels.
layout={{width: 320, height: 240, legend: {entrywidth: 0.2, entrywidthmode: "fraction"}}}
0
On

The only thing that helps me for now, is to add x value for the legend:

 legend: {
          x: 1.3,
          xanchor: "right"
    }