【发布时间】:2021-01-04 13:59:40
【问题描述】:
使用 matplotlib 我可以做到这一点:
import numpy as np
import matplotlib.pyplot as plt
fig, axs = plt.subplots(1, 2, figsize=(10, 5))
fig.patch.set_facecolor('white')
axs[0].bar(x=[0,1,2], height=[1,2,3])
axs[1].plot(np.random.randint(1, 10, 50))
axs[0].set_title('BARPLOT')
axs[1].set_title('WOLOLO')
在 plotly 中,我只知道一种设置子图标题的方法——在创建时:
fig = make_subplots(rows=1, cols=2, subplot_titles=('title1', 'title2'))
是否可以在创建后设置子图标题?
也许,通过访问 matplotlib 的原始 Axes 类(我读到了基于 matplotlib 的基于 seaborn 的 plotly.python)?
还是通过fig.layout?
请使用此代码:
import numpy as np
import plotly.graph_objects as go
from plotly.subplots import make_subplots
fig = make_subplots(rows=1, cols=2)
fig.add_trace(go.Bar(y=[1, 2, 3]), row=1, col=1)
fig.add_trace(go.Scatter(y=np.random.randint(1, 10, 50)), row=1, col=2)
【问题讨论】: