Hello everyone,
I had no trouble with Plotly until this incident.
For some of my plots, whenever I use Plotly express scatter plot with box plots on axes the strange boxplots in the first image happens.
Also, when I plot them using Plotly express box plot, it seems that there is no problem as can be seen in 2nd and 3rd images.
I attached the minimal code to reproduce it.
I hope if someone can explain to me what is going wrong and how to fix it.
Thanks!
# Imports
import plotly.express as px
import pandas as pd
# Minimal data
x = [0, 17.5, 35, 52.5, 70, 87.5, 105, 122.5]
y = [16.10142557, 27.15387483, 31.48277778, 47.98240741, 123.2, 44.97916667, 61.06666667, 122.37222222]
df = pd.DataFrame({'x':x, 'y':y})
fig = px.scatter(df, x='x', y='y', marginal_x='box', marginal_y='box', trendline='ols')
# Tried different combinations of them to see if anything changes
fig.update_layout(showlegend=False)
fig.update_yaxes(automargin=True)
fig.update_xaxes(automargin=True)
fig.show()
# Boxplot for x
fig = px.box(df, y='x')
fig.show()
# Boxplot for y
fig = px.box(df, y='y')
fig.show()