【发布时间】:2017-09-12 16:01:34
【问题描述】:
我有一个数据框,我想使用 pandas 将名为相似度的列绘制成直方图。这是我在 ipython 中使用的代码:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#%matplotlib inline throws an error but why?
%matplotlib auto
Df = pd.read_csv('file1.csv')
file1_hist = Df.hist(column= 'similarity', bins =50, color= 'red')
#setting labels for title and axes throws an error, why?
file1_hist.set_title('File 1 Histogram')
file1_hist.set_xlabel('similarity(%)')
file1_hist.set_ylabel('Frequency')
首先,我无法输入“%matplotlib inline”。错误为 UnknownBackend: No event loop integration for u'inline'. Supported event loops are: qt, qt4, qt5, gtk, gtk2, gtk3, tk, wx, pyglet, glut, osx 因此,我输入了 '%matplotlib auto' 但我不确定这是否正确。
另外,当我尝试添加标题/x/y 轴名称时,我收到一条错误消息:AttributeError: 'numpy.ndarray' object has no attribute 'set_title'
有人可以帮我解决这是怎么回事吗?
谢谢。
【问题讨论】: