tud7
May 11, 2020, 9:53pm
1
Is there a easy way for me to center my figure? When I use jupyter-nbconvert to convert to html, the figure is aligned on the right.
My code looks like this
fig = make_subplots(specs=[[{'secondary_y': True}]]) # I WANT TO CENTER THIS FIGURE
fig.add_trace(go.Bar(...))
fig.add_trace(go.Scatter...(),
secondary_y="True")
fig.update_layout(
title='My Plot',
barmode='overlay',
plot_bgcolor='rgb(245,245,245)',
legend=dict(
x=0.02,
y=0.95),
margin=dict(t=0, b=0, l=0, r=0)
)
Thanks
1 Like
Hi @tud7 welcome to the forum! Could you please attach screenshots to show what the problem is? With the zero margin which you are setting the figure (ie the axes domain) should be centered.
tud7
May 12, 2020, 5:35pm
3
Thank you!!!
You can see the plot is all the way to the left compared to the markdown. The markdown text is right-aligned.
It looks fine inside jupyter-notebook, but not in the generated html
I run the following command to convert to html:
jupyter-nbconvert --execute --no-input $IPYNB_FILE
-----
empet
May 12, 2020, 6:01pm
4
Hi @tud7
Please see the link from this old answer (2017): Centering Plotly Output on Jupyter Notebook . Iβm not sure if this method is still valid.
tud7
May 12, 2020, 11:18pm
5
Before I post this question, I saw that⦠but unfortunately, it does not work. I think the css class has changed.
empet
May 13, 2020, 4:48am
6
Hi @tud7 ,
In this case itβs better to address your question on Jupyter discourse, section Q&A:
https://discourse.jupyter.org/c/questions/18 .
1 Like