摘要:問題描述繪制函數(shù)上的點,請從以下選項中選出你認為正確的答案正確答案第題條形圖的繪制知識點描述繪制條形圖。
Matplotlib 是 Python 的繪圖庫,它提供了一整套和 matlab 相似的命令 API,可以生成出版質(zhì)量級別的精美圖形,Matplotlib 使繪圖變得非常簡單,我們就通過 10
道 Python
編程題來掌握使用 Matplotlib 庫進行圖形繪制吧!
知識點描述:繪制曲線圖。
問題描述:在同一圖片中繪制函數(shù) y = x 2 y=x^2 y=x2, y = l o g e x y=log_ex y=loge?x以及 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
知識點描述:繪制散點圖。
問題描述:繪制函數(shù) 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
知識點描述:繪制條形圖。
問題描述:繪制多組條形圖,比較不同年份相應(yīng)季度的銷量,請從以下選項中選出你認為正確的選項:
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
知識點描述:使用餅圖對比數(shù)量間的相對關(guān)系。
問題描述:繪制餅圖,對比列表 [10, 15, 30, 20] 數(shù)量間的相對關(guān)系,請從以下選項中選出你認為正確的選項:
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
知識點描述:使用直方圖表示概率分布。
問題描述:根據(jù)構(gòu)造數(shù)組繪制直方圖,請從以下選項中選出你認為正確的答案:
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
知識點描述:為圖形坐標軸的添加適當(dāng)描述標簽幫助用戶理解圖形所表達的含義。
問題描述:已知一函數(shù)用于描述加速運動,請繪制一圖形表示時間與距離間關(guān)系:
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
知識點描述:在圖形中添加說明文本,凸顯圖中點或線的重要性。
問題描述:使用文本顯式標記函數(shù)圖像的中點,請從以下選項中選出你認為正確的答案:
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
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/122572.html
摘要:問題描述已知存在二進制文件,如何正確向此文件追加寫入文本數(shù)據(jù),請從以下選項中選出你認為正確的答案正確答案第題壓縮文件的讀寫知識點描述讀寫或格式的壓縮文件。 僅需1...
摘要:積分技能樹征題前言第題具有函數(shù)表達式的被積函數(shù)求積分第題函數(shù)表達式未知的積分求解試題代碼地址前言積分在科學(xué)和工程應(yīng)用中具有許多重要的應(yīng)用,本文利用解決積分相關(guān)問題。 ...
摘要:屬于前一種,而且日益被用于數(shù)學(xué)計算機器學(xué)習(xí)和多種數(shù)據(jù)科學(xué)應(yīng)用。近來,由于擁有多個針對機器學(xué)習(xí)自然語言處理數(shù)據(jù)視覺化數(shù)據(jù)探索數(shù)據(jù)分析和數(shù)據(jù)挖掘的插件,豐富的數(shù)據(jù)科學(xué)生態(tài)體系得到了較大的發(fā)展,甚至有將數(shù)據(jù)科學(xué)社區(qū)化的趨勢。 譯者注:本文的英文原文地址是:Python for Data Science vs Python for Web Development,發(fā)布時間是10月29日。譯者一...
摘要:數(shù)據(jù)分析的發(fā)展方向一般有商業(yè)方向,行業(yè)分析業(yè)務(wù)方向,和機器學(xué)習(xí)數(shù)據(jù)挖掘方向。機器學(xué)習(xí)的書籍推薦統(tǒng)計學(xué)習(xí)方法,機器學(xué)習(xí),機器學(xué)習(xí)實戰(zhàn)三本書。 作者:xiaoyu 微信公眾號:Python數(shù)據(jù)科學(xué) 知乎:python數(shù)據(jù)分析師 上一篇主要分享了博主親身轉(zhuǎn)行數(shù)據(jù)分析的經(jīng)歷: 【從零學(xué)起到成功轉(zhuǎn)行數(shù)據(jù)分析,我是怎么做的?】 本篇繼上一篇將分享轉(zhuǎn)行數(shù)據(jù)分析的一些經(jīng)驗和學(xué)習(xí)方法,看完這篇你將會解...
閱讀 2894·2021-11-24 09:39
閱讀 3151·2021-11-19 10:00
閱讀 1552·2021-10-27 14:17
閱讀 1822·2021-10-14 09:43
閱讀 977·2021-09-03 10:30
閱讀 3421·2019-08-30 15:54
閱讀 2748·2019-08-30 13:05
閱讀 2021·2019-08-30 11:02