【发布时间】:2020-10-07 04:00:09
【问题描述】:
所以我有以下问题,需要使用提供的数据制作 3 个子图。我遇到的问题是我需要从“genre_1”列中为三个子图中的每一个选择一个特定的流派。我无法弄清楚如何选择特定数据。我已经提供了一个输出应该是什么样子的示例。
from plotly.subplots import make_subplots
import plotly.graph_objects as go
movies = {'title_year': {0: 2016, 1: 2016, 2: 2016, 3: 2016, 4:2016},'Title': {0: 'La La Land', 1: 'Zootopia',2: 'Lion',3: 'Arrival', 4: 'Manchester by the Sea'},'Runtime': {0: 128, 1: 108, 2: 118, 3: 116, 4: 137},'IMDb_rating': {0: 8.2, 1: 8.1, 2: 8.1, 3: 8.0, 4: 7.9},'genre_1': {0: 'Action',1: 'Animation',2: 'Biography',3: 'Drama',4: 'Drama'}}
# Create a subplot, using column, 'genre_1' for three genres - 'Action','Drama','Biography'
sub_fig = make_subplots(rows=1, cols=3)
fig.add_trace(go.Scatter(x='Runtime', y='IMDb_rating',row=1, col=1)
fig.add_trace(go.Scatter(x='Runtime', y='IMDb_rating',row=1, col=2)
fig.add_trace(go.Scatter(x='Runtime', y='IMDb_rating',row=1, col=3)
【问题讨论】:
-
请提供您的数据样本(不是图片)
-
编辑您的问题并将您的数据框粘贴到那里(请参阅here)
-
@DavideBrex 我已经添加了数据
标签: python pandas plotly subplot