日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

Python | 使用matplotlib.pyplot创建线图

發(fā)布時(shí)間:2023/12/1 python 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python | 使用matplotlib.pyplot创建线图 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Problem statement: Write a program in python (using matplotlib.pyplot) to create a line plot.

問題陳述:用python編寫程序(使用matplotlib.pyplot)以創(chuàng)建線圖。

Program:

程序:

import matplotlib.pyplot as pltx = [1,2,3,4,5,6,7,8,9,10] y = [3,9,6,12,5,1,10,5,4,9] plt.plot(x,y, label='lineplots', color='b') plt.xlabel('X-axis') plt.ylabel('Y-axis') plt.title('Line Plot') plt.legend() plt.show()

Output

輸出量

Explanation:

說明:

Python library matplotlib.pyplot is used to draw the above chart. Two random variables x and y are taken with random values. The plot function plots a line plot. The plot function takes 2 arguments i.e. x and y and a label variable gives the label to the plot. To name the axes xlabel and ylabel functions are used and to give the title to the plot the title function is used. To show the legend the legend function is used and finally to show the plot the show functions.

Python庫matplotlib.pyplot用于繪制以上圖表。 兩個(gè)隨機(jī)變量x和y帶有隨機(jī)值。 圖函數(shù)繪制線圖。 plot函數(shù)接受2個(gè)參數(shù),即x和y,以及一個(gè)label變量為該圖提供標(biāo)簽。 為了命名軸,使用了xlabel和ylabel函數(shù),并且使用了title函數(shù)為繪圖賦予標(biāo)題。 為了顯示圖例,使用了圖例功能,最后使用show函數(shù)顯示了情節(jié)。

翻譯自: https://www.includehelp.com/python/create-a-line-plot-using-matplotlib-pyplot.aspx

總結(jié)

以上是生活随笔為你收集整理的Python | 使用matplotlib.pyplot创建线图的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。