您可以更改情节中的子图标题位置吗?
Can you alter a subplot title location in plotly?
在情节中向我的子图添加 subplot_title 时,我的标题与我的坐标轴重叠。我可以像 matplotlib 那样更改子图标题的位置吗?ax.set_title('title', y=1.5)
?
这是我的情节,你可以看到舞蹈能力重叠:
到目前为止,这是我的代码:
from plotly.subplots import make_subplots
categories = ['key', 'acousticness', 'danceability', 'energy', 'loudness',
'speechiness', 'tempo','key']
fig = make_subplots(rows=1, cols=2, specs=[[{"type":"polar"}, {"type":"polar"}]],
subplot_titles=('Clustering Into 8 Playlists', 'Clustering Into 11 Playlists'))
fig.add_trace(go.Scatterpolar(
r=x,
theta=categories,
fill='toself',
name='Cluster 1',
visible='legendonly'
), row=1, col=1)
fig.add_trace(go.Scatterpolar(
r=y,
theta=categories,
fill='toself',
name='Cluster 2',
visible='legendonly'
), row=1, col=2)
fig.update_layout(height=600, width=1400, title_text='Radar Plot of All Clusters (Fig.4)')
fig.show()
我给出了部分代码答案,但你可以用 fig['layout']['annotations']
来完成。来自官方参考here.I also referred to .
fig.update_layout(title_text='Radar Plot of All Clusters (Fig.4)') # height=600, width=1400,
for annotation in fig['layout']['annotations']:
annotation['yanchor']='bottom'
annotation['y']=1.1
annotation['yref']='paper'
fig.show()
在情节中向我的子图添加 subplot_title 时,我的标题与我的坐标轴重叠。我可以像 matplotlib 那样更改子图标题的位置吗?ax.set_title('title', y=1.5)
?
这是我的情节,你可以看到舞蹈能力重叠:
到目前为止,这是我的代码:
from plotly.subplots import make_subplots
categories = ['key', 'acousticness', 'danceability', 'energy', 'loudness',
'speechiness', 'tempo','key']
fig = make_subplots(rows=1, cols=2, specs=[[{"type":"polar"}, {"type":"polar"}]],
subplot_titles=('Clustering Into 8 Playlists', 'Clustering Into 11 Playlists'))
fig.add_trace(go.Scatterpolar(
r=x,
theta=categories,
fill='toself',
name='Cluster 1',
visible='legendonly'
), row=1, col=1)
fig.add_trace(go.Scatterpolar(
r=y,
theta=categories,
fill='toself',
name='Cluster 2',
visible='legendonly'
), row=1, col=2)
fig.update_layout(height=600, width=1400, title_text='Radar Plot of All Clusters (Fig.4)')
fig.show()
我给出了部分代码答案,但你可以用 fig['layout']['annotations']
来完成。来自官方参考here.I also referred to
fig.update_layout(title_text='Radar Plot of All Clusters (Fig.4)') # height=600, width=1400,
for annotation in fig['layout']['annotations']:
annotation['yanchor']='bottom'
annotation['y']=1.1
annotation['yref']='paper'
fig.show()