我正在使用Jupyter笔记本和azure中的应用洞察来分析数据。我得到的数据如下,
{' xaxis':[' 2018-04-15T03:00:00Z',' 2018-04-15T07:00:00Z'],& #39; YAXIS&#39 ;: [62,26]}
我正在使用seaborn在条形图上绘制数据,
import seaborn as sns #modern visualization
并使用以下内容进行绘图,
sns.barplot(y = axes['yaxis'], x = axes['xaxis'], orient='h');
它抛出一个错误说
TypeError:/:' str'不支持的操作数类型和' int'
答案 0 :(得分:2)
一种方法是将方向改为v
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
axes = {'xaxis': ['2018-04-15T03:00:00Z', '2018-04-15T07:00:00Z'], 'yaxis': [62, 26]}
sns.barplot(y = axes['yaxis'], x = axes['xaxis'], orient='v');
结果:
要绘制水平线,您可以尝试更改x和y:
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
axes = {'xaxis': ['2018-04-15T03:00:00Z', '2018-04-15T07:00:00Z'], 'yaxis': [62, 26]}
sns.barplot(x = axes['yaxis'], y = axes['xaxis'], orient='h');
结果: