摘要:問題描述繪制函數上的點,請從以下選項中選出你認為正確的答案正確答案第題條形圖的繪制知識點描述繪制條形圖。
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=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
知識點描述:繪制散點圖。
問題描述:繪制函數 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
文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。
轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/122572.html
摘要:問題描述已知存在二進制文件,如何正確向此文件追加寫入文本數據,請從以下選項中選出你認為正確的答案正確答案第題壓縮文件的讀寫知識點描述讀寫或格式的壓縮文件。 僅需1...
摘要:積分技能樹征題前言第題具有函數表達式的被積函數求積分第題函數表達式未知的積分求解試題代碼地址前言積分在科學和工程應用中具有許多重要的應用,本文利用解決積分相關問題。 ...
摘要:屬于前一種,而且日益被用于數學計算機器學習和多種數據科學應用。近來,由于擁有多個針對機器學習自然語言處理數據視覺化數據探索數據分析和數據挖掘的插件,豐富的數據科學生態體系得到了較大的發展,甚至有將數據科學社區化的趨勢。 譯者注:本文的英文原文地址是:Python for Data Science vs Python for Web Development,發布時間是10月29日。譯者一...
摘要:數據分析的發展方向一般有商業方向,行業分析業務方向,和機器學習數據挖掘方向。機器學習的書籍推薦統計學習方法,機器學習,機器學習實戰三本書。 作者:xiaoyu 微信公眾號:Python數據科學 知乎:python數據分析師 上一篇主要分享了博主親身轉行數據分析的經歷: 【從零學起到成功轉行數據分析,我是怎么做的?】 本篇繼上一篇將分享轉行數據分析的一些經驗和學習方法,看完這篇你將會解...
閱讀 2887·2021-11-24 09:39
閱讀 3140·2021-11-19 10:00
閱讀 1541·2021-10-27 14:17
閱讀 1816·2021-10-14 09:43
閱讀 965·2021-09-03 10:30
閱讀 3419·2019-08-30 15:54
閱讀 2740·2019-08-30 13:05
閱讀 2016·2019-08-30 11:02