通过按钮绘制轴数据交换
Plotly Axis Data Swap by buttons
我正在尝试提供一个按钮,用于在 updatemenu
as
的帮助下在 2D 直方图图表的轴之间切换
Driver 代码是:
self._chartFigure.update_layout(
updatemenus=[
super().reverse_colorScale(self),
super().reverse_axis(self,
x=self._chartTypeObject.__getitem__("y"),
y=self._chartTypeObject.__getitem__("x"))
])
我试过这段代码:但它在点击后没有呈现任何东西,所以不确定它是否可行
def reverse_axis(self, x, y):
return dict(
buttons=list([
dict(args=[{"x": y, "y": x, "xbin.size": 0.2, "xbin.start": 0,"ybins.size": 1, "ybins.start": 0}],
label="Switch X to Y",
method="restyle"
),
dict(args=[{"x": x, "y": y,"xbin.size": 1, "xbin.start": 0, "ybins.size": 0.2, "ybins.start": 0}],
label="Switch Y to X",
method="update"
)
]),
type="dropdown",
direction="right",
showactive=True,
x=0.13,
y=1.065,
xanchor="center",
yanchor="bottom"
)
点击前:
点击后:
这里是答案,如果有人正在寻找它,这个答案是有效的
def reverse_axis(self, x, y):
return dict(
buttons=list([
dict(args=[{"x": [list(y)], "y": [list(x)], "xbin.size": 0.2, "xbin.start": 0,"ybins.size": 1, "ybins.start": 0}],
label="Switch X to Y",
method="restyle"
),
dict(args=[{"x": [list(x)], "y": [list(y)],"xbin.size": 1, "xbin.start": 0, "ybins.size": 0.2, "ybins.start": 0}],
label="Switch Y to X",
method="update"
)
]),
type="dropdown",
direction="right",
showactive=True,
x=0.13,
y=1.065,
xanchor="center",
yanchor="bottom"
)
我正在尝试提供一个按钮,用于在 updatemenu
as
Driver 代码是:
self._chartFigure.update_layout(
updatemenus=[
super().reverse_colorScale(self),
super().reverse_axis(self,
x=self._chartTypeObject.__getitem__("y"),
y=self._chartTypeObject.__getitem__("x"))
])
我试过这段代码:但它在点击后没有呈现任何东西,所以不确定它是否可行
def reverse_axis(self, x, y):
return dict(
buttons=list([
dict(args=[{"x": y, "y": x, "xbin.size": 0.2, "xbin.start": 0,"ybins.size": 1, "ybins.start": 0}],
label="Switch X to Y",
method="restyle"
),
dict(args=[{"x": x, "y": y,"xbin.size": 1, "xbin.start": 0, "ybins.size": 0.2, "ybins.start": 0}],
label="Switch Y to X",
method="update"
)
]),
type="dropdown",
direction="right",
showactive=True,
x=0.13,
y=1.065,
xanchor="center",
yanchor="bottom"
)
点击前:
点击后:
这里是答案,如果有人正在寻找它,这个答案是有效的
def reverse_axis(self, x, y):
return dict(
buttons=list([
dict(args=[{"x": [list(y)], "y": [list(x)], "xbin.size": 0.2, "xbin.start": 0,"ybins.size": 1, "ybins.start": 0}],
label="Switch X to Y",
method="restyle"
),
dict(args=[{"x": [list(x)], "y": [list(y)],"xbin.size": 1, "xbin.start": 0, "ybins.size": 0.2, "ybins.start": 0}],
label="Switch Y to X",
method="update"
)
]),
type="dropdown",
direction="right",
showactive=True,
x=0.13,
y=1.065,
xanchor="center",
yanchor="bottom"
)