我在 csv 文件中有一些数据集(总共 3 个),需要以不同的方式表示它。它们必然是带有 kde(核密度估计)的折线图、箱线图和直方图。
我知道如何单独绘制它们,但为了更方便,我需要将它们合并到一个输出中。在查阅参考资料后,我确实编写了一些代码,但它没有运行。
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import plotly.figure_factory as ff
import numpy as np
y1 = np.random.randn(200) - 1
y2 = np.random.randn(200)
y3 = np.random.randn(200) + 1
x = np.linspace(0, 1, 200)
fig = make_subplots(
rows=3, cols=2,
column_widths=[0.6, 0.4],
row_heights=[0.3, 0.6],
specs=[[{"type": "scatter"}, {"type": "box"}],
[{"type": "scatter"}, {"type": "dist", "rowspan": 2}]
[{"type": "scatter"}, None ]])
fig.add_trace(
go.Scatter(x = x,
y = y1,
hoverinfo = 'x+y',
mode='lines',
line=dict(color='rgb(0, 0, 0)',
width=1),
showlegend=False, …Run Code Online (Sandbox Code Playgroud)