如何使用matplotlib在Python上创建一个图,该数据集中所有来自数据集中的零的位置?
def plot_exam_versus_test_no_zeros(filename):
"""scatter plot, emitting zeros
"""
marks = np.loadtxt(filename, delimiter=',', skiprows=1, usecols=[2, 3])
zeros = marks[marks[:, :]==0] = np.nan
marks_test = marks[:, 0]
marks_exam = marks[:, 1]
axes = plt.axes()
axes.plot(marks_test, marks_exam, "go", label="markers")
axes.set_xlabel("Test")
axes.set_ylabel("Exam")
plt.title("COSC121: Exam versus Test")
plt.show()
plot_exam_versus_test_no_zeros("marks.csv")
到目前为止,这是我的代码的程度。我的情节看起来与应有的相同,但是测试中存在一些差异,如黄色所突出显示。
提前致谢。
这是一些照片...
https://i.sstatic.net/lvhj6.jpg
href =“ https://i.sstatic.net/de4jk.jpg” rel =“ nofollow noreferrer”> https://i.sstatic.net/de4jk.jpg
a /I.SSTATIC.NET/G1KD2.JPG“ RER =“ Nofollow Noreferrer”> https://i.sstatic.net/g1kd2.jpg
def plot_exam_versus_test_no_zeros(filename):
"""scatter plot, emitting zeros
"""
marks = np.loadtxt(filename, delimiter=',', skiprows=1, usecols=[2, 3])
zeros = marks[marks[:, :]==0] = np.nan
marks_test = marks[:, 0]
marks_exam = marks[:, 1]
axes = plt.axes()
axes.plot(marks_test, marks_exam, "go", label="markers")
axes.set_xlabel("Test")
axes.set_ylabel("Exam")
plt.title("COSC121: Exam versus Test")
plt.show()
plot_exam_versus_test_no_zeros("marks.csv")
This is the extent of my code so far. My plot looks identical to what it should, but there are a few differences in the test, as highlighted in yellow.
Thanks in advance.
Here's some photos...
https://i.sstatic.net/LVHJ6.jpg
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无需过度复杂〜
No need to over complicate ~