How to control graph size

Hello,

I am super newb so any help is appreciated. This is my first time using Dash and Plotly_Express and I am graphing different performance statistics captured by an application over the course of a 24 hour period. There are multiple graphs that are grouped into categories like cpu, network, io etc.

I am able to create the graphs, but the labels in my legend are all different lengths which then causes the physical size of my graph to change to accommodate the size of those legend names.

The end result is the timestamps dont line up on the page which is something I need to achieve.

the X axis of each graph needs to be the same length, which means the timestamps will all line up and then it will be great to view.

Pls help :slight_smile:

Hi @kbninja1333 welcome to the forum! You can do this by setting explicitly the domain of the xaxis, see https://plotly.com/python/axes/#setting-the-domain-of-the-axis for an example.

Hi Emmanuelle,

Thank you for the quick response. In the example you provided it uses syntax for plotly, but I am working in Dash so instead of having a fig, I am using dcc.graph to generate my graphs.

How would I implement this in dcc.graph, would it be part of β€˜layout’? And if so would you happen to have a link to the syntax for that?

Thanks again for your help, this is my first time graphing :slight_smile:

~scott

You can pass any plotly Figure object (a go.Figure, often called fig in the plotly doc) to the figure attribute of a dcc.Graph. So instead of a dictionary with data and layout keys, you pass a plotly figure. See https://plotly.com/python/creating-and-updating-figures/ and https://dash.plotly.com/dash-core-components/graph for more details.

Amazing thanks Emmanuelle, that worked perfectly!!