ValueError:无法将尺寸为50的序列复制到尺寸为1的数组轴

时间:2019-03-10 13:59:50

标签: python-3.x boxplot

我正在尝试运行以下脚本来绘制箱形图,但出现与第16行'ax.boxplot(data)'相关的标题错误。

# Plot boxplots for exam scores to evaluate any significant differences in exam scores.
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib
matplotlib.use('agg')
scores = pd.read_csv('ExamScores.csv')

exam1_score = scores[['Exam1']]
exam2_score = scores[['Exam2']]
exam3_score = scores[['Exam3']]
exam4_score = scores[['Exam4']]
data = [exam1_score, exam2_score, exam3_score, exam4_score]

fig = plt.figure()
ax = fig.add_subplot(111)
ax.boxplot(data)
fig.savefig('test.png')

数据文件在这里 https://www.dropbox.com/s/5chfdwyiu2sk0k9/ExamScores.csv?dl=0

0 个答案:

没有答案