1 year ago
#386559
Abhinav Choudhury
Increase size of the Violin plot such that it can properly fit the boxplot inside it in plotly
I was plotting multiple grouped violin plots in plotly but the violin plot is coming out too narrow (I have looked into this link Violin plots are narrow, but it's not solving my problem) and the boxplots are overflowing. Is it possible to enlarge the size of the violin plots so that the box plots can fit properly inside, without altering the size of the boxplots? I am attaching here the image and the code.
fig = make_subplots(rows=1, cols=1)
for t in px.violin(df, x="M", y="C", color="G", width = 50 ).data:
fig.add_trace(t, row=1, col=1)
# modifications needed to fix up display of sub-plots
fig.update_layout(
boxmode="group", margin={"l": 0, "r": 0, "t": 20, "b": 0}
).update_traces(showlegend=True)
fig.update_layout(boxgap=0, boxgroupgap=0)
fig.update_traces(meanline_visible=True,box_visible=True)
fig.update_layout(
violingap=0, violingroupgap=0,autosize=True,violinmode='group',
#legend_title = dict(font = dict(family = "Courier", size = 30, color = "blue")),
legend=dict(
#itemsizing='constant',
yanchor="top",
y=0.99,
xanchor="left",
x=0.005,
font=dict(
family="Courier",
size=45,
color="#000033"
),
),
width=1800,
height=1200,
plot_bgcolor='rgb(255, 255, 255)',
yaxis=dict(
title_text="",
ticktext=["Very long label", "long label", "3", "label"],
titlefont=dict(size=45),
linecolor='#000033', # Sets color of X-axis line
showgrid=False, # Removes X-axis grid lines
linewidth=15
),
xaxis = dict(
tickmode = 'array',
linecolor='#000033', # Sets color of X-axis line
linewidth=15,
showgrid=False # Removes X-axis grid lines
),
font=dict(
# family="Arial Black, monospace",
family="Arial, monospace",
size=45,
color="#000033"
),)
fig.write_image('1.png',format="png", width=1400, height=1200, scale=2)`
Kindly help.
Thank you
plotly
plotly-python
0 Answers
Your Answer