python - Plotly y 轴表现滑稽
问题描述
所以,我的条形图 y 轴一直表现得很有趣。这是图表,
取而代之的是一个范围,比如 0 - 100,这些值无处不在。我不明白为什么。这是我的代码:
uni_list = ['Harvard University',
'California Institute of Technology',
'Massachusetts Institute of Technology',
'Stanford University',
'Princeton University',
'University of Cambridge',
'University of Oxford',
'University of California, Berkeley',
'Imperial College London',
'Yale University']
year_list = [2011, 2012, 2013, 2014, 2015, 2016]
int_std = pd.DataFrame(columns=['university_name', 'year', 'income'])
count = 0
print(int_std)
for university in uni_list:
for year in year_list:
int_std.loc[count, 'university_name'] = university
int_std.loc[count, 'year'] = year
int_std.loc[count, 'income'] = times[(times['university_name'] == university) & (times['year'] == year)]['income'].iloc[0]
count = count + 1
bar1 = go.Bar(x = uni_list,
y = int_std[int_std['year'] == 2011].income.values,
marker = dict(color = 'yellow', line=dict(color='white', width = 1)),
name = '2011')
bar2 = go.Bar(x = uni_list,
y = int_std[int_std['year'] == 2012].income.values,
marker = dict(color = 'orange', line=dict(color='white', width = 1)),
name = '2012')
bar3 = go.Bar(x = uni_list,
y = int_std[int_std['year'] == 2013].income.values,
marker = dict(color = 'green', line=dict(color='white', width = 1)),
name = '2013')
bar4 = go.Bar(x = uni_list,
y = int_std[int_std['year'] == 2014].income.values,
marker = dict(color = 'blue', line=dict(color='white', width = 1)),
name = '2014')
bar5 = go.Bar(x = uni_list,
y = int_std[int_std['year'] == 2015].income.values,
marker = dict(color = 'red', line=dict(color='white', width = 1)),
name = '2015')
bar6 = go.Bar(x = uni_list,
y = int_std[int_std['year'] == 2016].income.values,
marker = dict(color = 'grey', line=dict(color='white', width = 1)),
name = '2016')
fig3 = go.Figure(data = [bar1, bar2, bar3, bar4, bar5], layout = go.Layout(barmode = 'group'))
py.plot(fig3)
我使用的数据集来自这里:
https://www.kaggle.com/kanncaa1/plotly-tutorial-for-beginners
我注意到我尝试绘制的任何条形图都会出现这个问题。我不知道为什么。非常感谢您的帮助。
解决方案
推荐阅读
- angular - 列表的进度百分比
文件从 Angular FormData 到 ASP.NET Core 错误的百分比值 - python - 即使在我的 Raspberry 4 上成功安装 pip 后,也没有名为“...”的模块
- go - 无法在 GO 的 swagger UI 的标头中传递 jwt 令牌
- r - R - 未转换为类的数值变量
- python - 如何使用pygame中的套接字让其他人在多人游戏中看到我的精灵动画
- react-native - React Native:在坐标数组之间导航
- python - 如果列表中的所有值都是 40,则 Python 返回成功
- r - 嘎嘎也嫉妒你电脑上的其他库吗?
- openlayers - openlayers v6中的自定义网格/刻度
- mongodb - MongoDB大数组在文档中的表现