最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python matplotlib折線圖樣式實(shí)現(xiàn)過(guò)程

 更新時(shí)間:2019年11月04日 11:40:35   作者:changfan  
這篇文章主要介紹了python matplotlib折線圖樣式實(shí)現(xiàn)過(guò)程,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

這篇文章主要介紹了python matplotlib折線圖樣式實(shí)現(xiàn)過(guò)程,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

一:簡(jiǎn)單的折線圖

import matplotlib.pyplot as plt

#支持中文顯示
plt.rcParams["font.sans-serif"]=["SimHei"]

#x,y數(shù)據(jù)
x_data = [1,2,3,4,5]
y_data = [10,30,20,25,28]

plt.plot(x_data,y_data)

plt.title("簡(jiǎn)單的折線圖")
plt.xlabel("x")
plt.ylabel("y")

plt.show()

二、多折線折線圖

import matplotlib.pyplot as plt

#x,y數(shù)據(jù)
x_data = [1,2,3,4,5]
y_data = [10,30,20,25,28]
y_data_1 = [12,32,22,27,30]
y_data_2 = [8,28,18,23,25]
plt.plot(x_data,y_data,x_data,y_data_1,x_data,y_data_2)
"""
plt.plot(x_data,y_data,x_data,y_data_1)
此行可替代為
plt.plot(x_data,y_data)
plt.plot(x_data,y_data_1)
plt.plot(x_data,y_data_2)

"""
plt.show()

三、折線樣式:折線顏色、折線圖案 、折線寬度

import matplotlib.pyplot as plt
#x,y數(shù)據(jù)
x_data = [1,2,3,4,5]

y_data = [10,30,20,25,28]
y_data_1 = [12,32,22,27,30]
plt.plot(x_data,y_data,color="red",linewidth=2.0,linestyle="--")
plt.plot(x_data,y_data_1,color="blue",linewidth=2.0,linestyle="-.")
plt.show()

注:

①color參數(shù):

  • 顏色名稱或簡(jiǎn)寫(xiě)#rrggbb
    • b: blue
    • g: green
    • r: red
    • c: cyan
    • m: magenta
    • y: yellow
    • k: black
    • w: white
  • #rrggbb
  • (r, g, b) 或 (r, g, b, a),其中 r g b a 取均為[0, 1]之間
  • [0, 1]之間的浮點(diǎn)數(shù)的字符串形式,表示灰度值。0表示黑色,1表示白色

②linestyle參數(shù)

-:代表實(shí)線,這是默認(rèn)值;

--:代表虛線;

·:代表點(diǎn)錢(qián);

-.:代表短線、點(diǎn)相間的虛錢(qián)

四、折線圖的注解

import numpy as np
import matplotlib.pyplot as plt

#x,y數(shù)據(jù)
x_data = np.linspace(0, 2 * np.pi, 100)
y_data, y2_data = np.sin(x_data), np.cos(x_data)


plt.plot(x_data,y_data,label="y=sinx")
plt.plot(x_data,y2_data,label="y=cosx")
plt.legend()

plt.show()

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

沂水县| 任丘市| 大关县| 石楼县| 理塘县| 杂多县| 增城市| 广平县| 哈尔滨市| 晋州市| 岑溪市| 阿勒泰市| 偃师市| 博爱县| 临湘市| 邵东县| 淮阳县| 上饶市| 武平县| 永丰县| 蚌埠市| 平乐县| 曲水县| 曲周县| 宜兰市| 遂溪县| 扎赉特旗| 鹿泉市| 云和县| 和平区| 永昌县| 阿克| 嘉禾县| 永春县| 明光市| 苗栗市| 长治市| 望奎县| 兴和县| 麻栗坡县| 稷山县|