新聞中心
一直講函數(shù)和代碼有些煩悶,今天我們來學(xué)點(diǎn)好玩的,用python畫一個(gè)坐標(biāo)類的圖吧。

在西鄉(xiāng)塘等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、外貿(mào)營銷網(wǎng)站建設(shè) 網(wǎng)站設(shè)計(jì)制作按需求定制設(shè)計(jì),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站設(shè)計(jì),全網(wǎng)營銷推廣,外貿(mào)網(wǎng)站制作,西鄉(xiāng)塘網(wǎng)站建設(shè)費(fèi)用合理。
在畫之前,首先導(dǎo)入所用包及相關(guān)設(shè)置。
import pandas as pd import numpy as np import matplotlib.pyplot as plt %matplotlib inline
散點(diǎn)圖將所有的數(shù)據(jù)以點(diǎn)的形式展現(xiàn)在坐標(biāo)系上,可以觀察數(shù)據(jù)點(diǎn)的分布情況,在直角坐標(biāo)系,可以推斷變量間的相關(guān)性,而在極坐標(biāo)上,更側(cè)重?cái)?shù)據(jù)的分布及離散情況。
#生成范例數(shù)據(jù)
r = 2 * np.random.rand(100) #生成100個(gè)服從“0~1”均勻分布的隨機(jī)樣本值 theta = 2 * np.pi * np.random.rand(100) #生成角度 area = 100 * r**2 #面積 colors = theta #顏色 ax = plt.subplot(111, projection='polar') #projection為畫圖樣式,除'polar'外還有'aitoff', 'hammer', 'lambert'等 c = ax.scatter(theta, r, c=colors, s=area, cmap='cool', alpha=0.75) #ax.scatter為繪制散點(diǎn)圖函數(shù) plt.show()
所作圖形如下所示,可以看到散點(diǎn)在極坐標(biāo)上的分布情況,以及散點(diǎn)自身特點(diǎn)(如大小、顏色等)情況。
看起來還挺好看的,感興趣小伙伴快行動(dòng)起來。更多Python學(xué)習(xí)推薦:PyThon學(xué)習(xí)網(wǎng)教學(xué)中心。
網(wǎng)站名稱:創(chuàng)新互聯(lián)Python教程:如何用python畫極坐標(biāo)散點(diǎn)圖?
文章來源:http://www.5511xx.com/article/dpijheg.html


咨詢
建站咨詢
