When i change xaxis data from Dropdowns then plotly.histogram fails.
With yaxis works.
¿Any suggestion?
# -*- coding: utf-8 -*-
"""
Created on Fri Nov 25 16:59:14 2022
@author: daekka
"""
# Libraries
import pandas as pd
import numpy as np
import plotly.express as px
import plotly.io as pio
pio.renderers.default='browser'
# Create the pandas DataFrame
dates = pd.date_range("20130101", periods=600)
df = pd.DataFrame(np.random.randn(600, 4), index=dates, columns=list("ABCD"))
# Create plot
fig = px.scatter(df, x= df.columns[0] , y=df.columns[0], marginal_x="histogram", marginal_y="histogram")
# Update layout
fig.update_layout(
updatemenus=[
{
"buttons": [
{
"label": c,
"method": "update",
"args": [
{axis: [df[c]]},
{f"{axis}axis": {"title": {"text": c}}},
],
}
for c in df.columns
],
"x": 0 if axis == "x" else 0.4,
"y": 1.2,
}
for axis in "xy"
]
)
fig.show()