我阅读了相同的 github 页面,我认为这是不可能的,但似乎是!我只检查了 Python,但我希望这将有助于您在 R 中的努力以及在 Python 中寻找信息的每个人。遗憾的是,与其他软件包相比,这里没有太多关于 Plotly 的信息。
这解决了我的问题
设置orientation='h' 是不够的。如果您希望将图例项放在不同的列中,您还必须将它们放在不同的legendgroups 中。这是一个带有图例标签的示例:
fig = go.Figure([
go.Scatter(x=best_neurons_df['Test Size'],
y=best_neurons_df['Training Accuracy Max'],
# You can write anything as the group name, as long as it's different.
legendgroup="group2",
name='Training',
mode='markers',
go.Scatter(x=best_neurons_df['Test Size'],
y=best_neurons_df['Validation Accuracy Max'],
# You can write anything as the group name, as long as it's different.
legendgroup="group1",
layout=dict(title='Best Model Dependency on Validation Split',
xaxis=dict(title='Validation Set proportion'),
yaxis=dict(title='Accuracy'),
margin=dict(b=100, t=100, l=0, r=0),
legend=dict(x=1, y=1.01,xanchor='right', yanchor='bottom',
title='',
orientation='h', # Remember this as well.
bordercolor='black',
borderwidth=1
))
Example image