摘要:问题描述绘制函数上的点,请从以下选项中选出你认为正确的答案正确答案第题条形图的绘制知识点描述绘制条形图。
Matplotlib 是 Python 的绘图库,它提供了一整套和 matlab 相似的命令 API,可以生成出版质量级别的精美图形,Matplotlib 使绘图变得非常简单,我们就通过 10
道 Python
编程题来掌握使用 Matplotlib 库进行图形绘制吧!
知识点描述:绘制曲线图。
问题描述:在同一图片中绘制函数 y = x 2 y=x^2 y=x2, y = l o g e x y=log_ex y=logex以及 y = s i n ( x ) y=sin(x) y=sin(x),请从以下选项中选出你认为正确的答案:
A.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0.1, 2 * np.pi, 100)y_1 = np.square(x)y_2 = np.log(x)y_3 = np.sin(x)fig = plt.figure()plt.plot(x,y_1)fig = plt.figure()plt.plot(x,y_2)fig = plt.figure()plt.plot(x,y_3)plt.show()
B.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0.1, 2 * np.pi, 100)y_1 = np.square(x)y_2 = np.log(x)y_3 = np.sin(x)fig = plt.figure()plt.plot(x,y_1)plt.plot(x,y_2)plt.plot(x,y_3)plt.show()
C.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0.1, 2 * np.pi, 100)y_1 = np.square(x)y_2 = np.log(x)y_3 = np.sin(x)plt.plot(x,y_1, y_2, y_3)plt.show()
D.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0.1, 2 * np.pi, 100)y_1 = np.square(x)y_2 = np.log(x)y_3 = np.sin(x)fig = plt.figure()plt.plot(x,y_1, y_2, y_3)plt.show()
正确答案: B
知识点描述:绘制散点图。
问题描述:绘制函数 y = s i n ( x ) y=sin(x) y=sin(x)上的点,请从以下选项中选出你认为正确的答案:
A.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0.1, 2 * np.pi, 50)y = np.sin(x)fig = plt.figure()plt.plot(x, y)plt.show()
B.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0.1, 2 * np.pi, 50)y = np.sin(x)fig = plt.figure()plt.barh(x, y)plt.show()
C.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0.1, 2 * np.pi, 50)y = np.sin(x)fig = plt.figure()plt.bar(x, y)plt.show()
D.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0.1, 2 * np.pi, 50)y = np.sin(x)fig = plt.figure()plt.scatter(x, y)plt.show()
正确答案: D
知识点描述:绘制条形图。
问题描述:绘制多组条形图,比较不同年份相应季度的销量,请从以下选项中选出你认为正确的选项:
A.
import numpy as npimport matplotlib.pyplot as pltdata = [[10., 20., 30., 20.],[40., 25., 53., 18.],[6., 22., 52., 19.]]x = np.arange(4)colors = ["r", "g", "b"]for i in range(len(data)): plt.bar(x + i * 0.25, data[:i], color = colors[i], width = 0.25)plt.show()
B.
import numpy as npimport matplotlib.pyplot as pltdata = [[10., 20., 30., 20.],[40., 25., 53., 18.],[6., 22., 52., 19.]]x = np.arange(4)colors = ["r", "g", "b"]for i in range(len(data)): plt.plot(x + i * 0.25, data[:i], color = colors[i], width = 0.25)plt.show()
C.
import numpy as npimport matplotlib.pyplot as pltdata = [[10., 20., 30., 20.],[40., 25., 53., 18.],[6., 22., 52., 19.]]x = np.arange(4)colors = ["r", "g", "b"]for i in range(len(data)): plt.bar(x + i * 0.25, data[i], color = colors[i], width = 0.25)plt.show()
D.
import numpy as npimport matplotlib.pyplot as pltdata = [[10., 20., 30., 20.],[40., 25., 53., 18.],[6., 22., 52., 19.]]x = np.arange(4)colors = ["r", "g", "b"]for i in range(len(data)): plt.plot(x + i * 0.25, data[i], color = colors[i], width = 0.25)plt.show()
正确答案: C
知识点描述:使用饼图对比数量间的相对关系。
问题描述:绘制饼图,对比列表 [10, 15, 30, 20] 数量间的相对关系,请从以下选项中选出你认为正确的选项:
A.
import matplotlib.pyplot as pltdata = [10, 15, 30, 20]sum_data = sum(data)plt.pie(data / sum_data)plt.show()
B.
import matplotlib.pyplot as pltdata = [10, 15, 30, 20]plt.pie(sum(data))plt.show()
C.
import matplotlib.pyplot as pltdata = [10, 15, 30, 20]plt.pie(range(len(data)), data)plt.show()
D.
import matplotlib.pyplot as pltdata = [10, 15, 30, 20]plt.pie(data)plt.show()
正确答案: D
知识点描述:使用直方图表示概率分布。
问题描述:根据构造数组绘制直方图,请从以下选项中选出你认为正确的答案:
A.
import numpy as npimport matplotlib.pyplot as pltx = np.random.randn(1024)plt.hist(x, bins = 20)plt.show()
B.
import numpy as npimport matplotlib.pyplot as pltx = np.random.randn(1024)plt.hist(x, bins=x.shape)plt.show()
C.
import numpy as npimport matplotlib.pyplot as pltx = np.random.randn(1024)plt.hist(x.shape, x)plt.show()
D.
import numpy as npimport matplotlib.pyplot as pltx = np.random.randn(1024)plt.hist(x, x.shape)plt.show()
正确答案: A
知识点描述:在图形中添加标题。
问题描述:为所绘制的图形添加中文标题,请从以下选项中选出你认为正确的答案:
A.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(-4, 4, 10005)y = 5 * (x + 4.2) * (x + 4.) * (x - 2.5)plt.title("曲线")plt.plot(x, y, c = "m")plt.show()
B.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(-4, 4, 10005)y = 5 * (x + 4.2) * (x + 4.) * (x - 2.5)plt.title("曲线")plt.plot(x, y, c = "m")plt.rcParams["font.sans-serif"] = ["SimSun"]plt.show()
C.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(-4, 4, 10005)y = 5 * (x + 4.2) * (x + 4.) * (x - 2.5)plt.plot(x, y, c = "m", title="曲线")plt.show()
D.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(-4, 4, 10005)y = 5 * (x + 4.2) * (x + 4.) * (x - 2.5)plt.plot(x, y, c = "m", title="曲线")plt.rcParams["font.sans-serif"] = ["SimSun"]plt.show()
正确答案: B
知识点描述:为图形坐标轴的添加适当描述标签帮助用户理解图形所表达的含义。
问题描述:已知一函数用于描述加速运动,请绘制一图形表示时间与距离间关系:
A.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0, 8, 1000)y = 2.0 * x + 0.5 * 5 * x ** 2plt.xtitle("Time")plt.ytitle("distance")plt.plot(x, y, c = "c")plt.show()
B.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0, 8, 1000)y = 2.0 * x + 0.5 * 5 * x ** 2plt.plot(x, y, c = "c", xlabel = "Time", ylable = "distance")plt.show()
C.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0, 8, 1000)y = 2.0 * x + 0.5 * 5 * x ** 2plt.plot(x, y, c = "c", xtitle = "Time", ytitle = "distance")plt.show()
D.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0, 8, 1000)y = 2.0 * x + 0.5 * 5 * x ** 2plt.xlabel("Time")plt.ylabel("distance")plt.plot(x, y, c = "c")plt.show()
正确答案:D
知识点描述:在图形中添加说明文本,凸显图中点或线的重要性。
问题描述:使用文本显式标记函数图像的中点,请从以下选项中选出你认为正确的答案:
A.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0, 8, 1000)y = 2.0 * x + 0.5 * 5 * x ** 2x_mid = x[0]y_mid = y[0]plt.scatter(x_mid, y_mid)plt.text(x_mid, y_mid, "mid")plt.plot(x, y, c = "c")plt.show()
B.
import numpy as npimport matplotlib.pyplot as pltx = np.linspace(0, 8, 1000)y = 2.0 * x + 0.5 * 5 * x ** 2x_mid = (x[-1] - x[0]) / 2y_mid = 2.0 * ((x[-1] - x[0
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/122572.html
摘要:问题描述已知存在二进制文件,如何正确向此文件追加写入文本数据,请从以下选项中选出你认为正确的答案正确答案第题压缩文件的读写知识点描述读写或格式的压缩文件。 仅需1...
摘要:积分技能树征题前言第题具有函数表达式的被积函数求积分第题函数表达式未知的积分求解试题代码地址前言积分在科学和工程应用中具有许多重要的应用,本文利用解决积分相关问题。 ...
摘要:属于前一种,而且日益被用于数学计算机器学习和多种数据科学应用。近来,由于拥有多个针对机器学习自然语言处理数据视觉化数据探索数据分析和数据挖掘的插件,丰富的数据科学生态体系得到了较大的发展,甚至有将数据科学社区化的趋势。 译者注:本文的英文原文地址是:Python for Data Science vs Python for Web Development,发布时间是10月29日。译者一...
摘要:数据分析的发展方向一般有商业方向,行业分析业务方向,和机器学习数据挖掘方向。机器学习的书籍推荐统计学习方法,机器学习,机器学习实战三本书。 作者:xiaoyu 微信公众号:Python数据科学 知乎:python数据分析师 上一篇主要分享了博主亲身转行数据分析的经历: 【从零学起到成功转行数据分析,我是怎么做的?】 本篇继上一篇将分享转行数据分析的一些经验和学习方法,看完这篇你将会解...
阅读 2855·2021-11-24 09:39
阅读 3084·2021-11-19 10:00
阅读 1506·2021-10-27 14:17
阅读 1789·2021-10-14 09:43
阅读 939·2021-09-03 10:30
阅读 3399·2019-08-30 15:54
阅读 2701·2019-08-30 13:05
阅读 1971·2019-08-30 11:02