How to shrink only the size of the graph


I know, that I’m able to change the size of the figure itself with:

go.Layout(width=1000, height=1000)

But this will change the size of the complete figure, including the size for the legend bar, etc.
Is it possible to just change the size of the graph in the figure? So that my legend has more space?

As you can see in the picture below, my graph is way to big. I just want to shrink the graph itself, without decreasing the size of the resulting pdf image.

So the resulting pdf image should more look like this (I edited with paint):

I found the same question here: How to change graph size/scale
But no answer…

Can you post the full code? thanks

It’s like several hundred lines of code… are you sure? :smiley:

Hi @winklerrr and @ilemi, you can set the margins of the figure explicitly, and move the legend position, for example

import as px
df =
fig = px.bar_polar(df, r="frequency", theta="direction",
                   color="strength", template="plotly_dark",
                   color_discrete_sequence= px.colors.sequential.Plasma_r)
fig.update_layout(margin_r=300, legend_x=1.4)

Hope this helps!