我是pyspark的新手,我正在尝试使用名为Movielens100k的在线公开的样本数据集。我通过命令行使用Pyspark。
当我尝试创建直方图时,它不会显示。我收到消息"这个插件不支持propagateSizeHints()"然后当我再次尝试命令使直方图出现时,没有任何反应。没有错误,没有输出或任何东西。这是我的代码:
>>> import numpy
>>> import pandas
>>> import sklearn
>>> import os
>>> os.environ['QT_QPA_PLATFORM']='offscreen'
>>> import matplotlib.pyplot
>>> user_data = sc.textFile("...../ml-100k/u.user")
>>> user_fields = user_data.map(lambda line: line.split("|"))
>>> ages = user_fields.map(lambda x: int(x[1])).collect()
>>> import pylab
>>> pylab.hist(ages, bins=20, color='lightblue', normed=True)
这是此时的输出:
QFontDatabase: Cannot find font directory
/var/hadoop/anaconda2/lib/fonts - is Qt installed correctly?
QFontDatabase: Cannot find font directory
/var/hadoop/anaconda2/lib/fonts - is Qt installed correctly?
QFontDatabase: Cannot find font directory
/var/hadoop/anaconda2/lib/fonts - is Qt installed correctly?
QFontDatabase: Cannot find font directory
/var/hadoop/anaconda2/lib/fonts - is Qt installed correctly? (array([
0.00064269, 0.00192808, 0.00449886, 0.0279572 , 0.02956393,
0.03374144, 0.04563129, 0.02538642, 0.02088756, 0.01863813,
0.02088756, 0.01606735, 0.0170314 , 0.01863813, 0.00674829,
0.00482021, 0.0054629 , 0.00192808, 0.00128539, 0.00128539]), array([ 7. , 10.3, 13.6, 16.9, 20.2, 23.5, 26.8, 30.1, 33.4,
36.7, 40. , 43.3, 46.6, 49.9, 53.2, 56.5, 59.8, 63.1,
66.4, 69.7, 73. ]), <a list of 20 Patch objects>)
然后,当我尝试渲染图形时,会发生这种情况:
>>> fig = matplotlib.pyplot.gcf()
>>> fig.set_size_inches(16, 10)
>>> fig.show()
This plugin does not support propagateSizeHints()
>>> fig.show()
>>>
请让我知道如何解决此问题并显示直方图。谢谢!