plotly / plotly.py

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!
https://plotly.com/python/
MIT License
16.19k stars 2.55k forks source link

px.ecdf // x_log leads to shifted marginal histogram #3507

Open ChrisOKay opened 2 years ago

ChrisOKay commented 2 years ago

When trying to display a marginal histogram combined with log_x = true, the histogram does not seem to get placed correclty.

Minimal reproducible example (plotly 5.4.0):

import plotly.express as px
import pandas as pd
import numpy as np

df = pd.DataFrame({'data': np.random.randn(10000)+8})
fig = px.ecdf(df, x='data', marginal='histogram', log_x=True)
fig.show()

I expect the histogram's median at 8 (normal distribution with offset of 8), but it is placed somewhere at more than 11. The actual ecdf is displayed correctly. With log_x = False, both the histogram and the ecdf are displayed correctly.

eisenlohr commented 2 years ago

It is even weirder since the peak of the marginal histogram depends on the number of samples...

ecdf_marginalHistogram_1000 ecdf_marginalHistogram_10000 ecdf_marginalHistogram_100000 ecdf_marginalHistogram_1000000