Setting height/width of subplot

I can find how to set the width/height of the figure by changing the โ€˜layoutโ€™ attribute. How can I set height/width of individual subplots? Is this functionality available?

Hi there,

For individual heights/widths of subplots, check out this tutorial:

You need to fiddle with the xaxis/yaxis domains to get a proportion that you want.

Hope this helps!

1 Like

Thanks Adam,
I am able to change the xaxis/yaxis domains as per the tutorial. But it appears to be a relative size (since it normalizes to 1). What I want to be able to do is to set a size in pixels for width and height for individual subplots. this way I can ensure, the plots donโ€™t become tiny when I am plotting 10 rows x 10 cols. I am ok with scrolling the page in my browser to see the plots. Is there a way to do that?

Example of what I am referring toโ€ฆ

@Adam, just checking back to see if you had any insights. If there is no way around it, it would be helpful to know :slight_smile:

If you want to set width/height of subplots in pixels you first
set the layout.height, layout.width,, layout.margin.bottom,layout.margin.left, layout.margin.right, in pixels.

Then the plotting rectangle has the width =layout.width - layout.margin.left - layout.margin.right
and the height= layout.height - - layout.margin.bottom.
In such a rectangle you set the width and height of each subplot, in pixels.

Then you define a scaling map from the rectangle
[0, layout.width - layout.margin.left - layout.margin.right]x[0, layout.height - - layout.margin.bottom] to the rectangle [0,1]x [0,1].
This mapping let you find out the domain for the xaxis, yaxis associated to your subplots.

1 Like

Thanks @empet. This does the trick!

Would anyone mind posting some small code example of how to fix a constant height for each subplot? Iโ€™m basically aiming for something as @siddharthm in Setting height/width of subplot , trying to create new (sub-)plots in Dash on button click. Iโ€™ve been experimenting with layout = go.Layout(..., figure.layout.update(... and figure['layout'][... but I cannot get it to work properly.
Any help would be much appreciated!

@ siddharthm can you post a snippet of your code?
got lost with all the params here and where to put them
I want exactly what you did - only 2 columns instead of three

Hi Siddharth,

could it be possible for you to share this portion of your code.

thank you very much in advance for your help