Python+matplotlib繪制不同大小和顏色散點(diǎn)圖實(shí)例
具有不同標(biāo)記顏色和大小的散點(diǎn)圖演示。
演示結(jié)果:

實(shí)現(xiàn)代碼:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
# Load a numpy record array from yahoo csv data with fields date, open, close,
# volume, adj_close from the mpl-data/example directory. The record array
# stores the date as an np.datetime64 with a day unit ('D') in the date column.
with cbook.get_sample_data('goog.npz') as datafile:
price_data = np.load(datafile)['price_data'].view(np.recarray)
price_data = price_data[-250:] # get the most recent 250 trading days
delta1 = np.diff(price_data.adj_close) / price_data.adj_close[:-1]
# Marker size in units of points^2
volume = (15 * price_data.volume[:-2] / price_data.volume[0])**2
close = 0.003 * price_data.close[:-2] / 0.003 * price_data.open[:-2]
fig, ax = plt.subplots()
ax.scatter(delta1[:-1], delta1[1:], c=close, s=volume, alpha=0.5)
ax.set_xlabel(r'$\Delta_i$', fontsize=15)
ax.set_ylabel(r'$\Delta_{i+1}$', fontsize=15)
ax.set_title('Volume and percent change')
ax.grid(True)
fig.tight_layout()
plt.show()
總結(jié)
以上就是本文關(guān)于Python+matplotlib繪制不同大小和顏色散點(diǎn)圖實(shí)例的全部?jī)?nèi)容,希望對(duì)大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站其他相關(guān)專題,如有不足之處,歡迎留言指出。感謝朋友們對(duì)本站的支持!
- python學(xué)習(xí)之matplotlib繪制散點(diǎn)圖實(shí)例
- Python?Matplotlib實(shí)現(xiàn)三維數(shù)據(jù)的散點(diǎn)圖繪制
- 使用matplotlib中scatter方法畫(huà)散點(diǎn)圖
- Python利用matplotlib繪制散點(diǎn)圖的新手教程
- Python使用Matplotlib繪制三維散點(diǎn)圖詳解流程
- python3使用matplotlib繪制散點(diǎn)圖
- Python matplotlib繪制散點(diǎn)圖的實(shí)例代碼
- 使用matplotlib畫(huà)散點(diǎn)圖的方法
- matplotlib一維散點(diǎn)分布圖的實(shí)現(xiàn)
相關(guān)文章
使用Python實(shí)現(xiàn)從各個(gè)子文件夾中復(fù)制指定文件的方法
今天小編就為大家分享一篇使用Python實(shí)現(xiàn)從各個(gè)子文件夾中復(fù)制指定文件的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-10-10
pycharm如何實(shí)現(xiàn)跨目錄調(diào)用文件
這篇文章主要介紹了pycharm如何實(shí)現(xiàn)跨目錄調(diào)用文件,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-02-02
Python的Flask框架中配置多個(gè)子域名的方法講解
Fask中可以通過(guò)通配符子域的方式來(lái)部署多個(gè)子域名,這里我們就來(lái)作一個(gè)Python的Flask框架中配置多個(gè)子域名的方法講解,需要的朋友可以參考下2016-06-06
python中判斷類型函數(shù)isinstance()示例詳解
isinstance()函數(shù)是Python的內(nèi)置函數(shù),用于判斷一個(gè)變量是否是某個(gè)類型或者是該類型的子類的實(shí)例,在Python中,所有類都繼承自object,所以任何實(shí)例都會(huì)是object的實(shí)例,本文給大家介紹python中判斷類型函數(shù)isinstance(),感興趣的朋友一起看看吧2024-10-10
Python?計(jì)算機(jī)視覺(jué)編程進(jìn)階之圖像特效處理篇
計(jì)算機(jī)視覺(jué)這種技術(shù)可以將靜止圖像或視頻數(shù)據(jù)轉(zhuǎn)換為一種決策或新的表示。所有這樣的轉(zhuǎn)換都是為了完成某種特定的目的而進(jìn)行的,本篇我們來(lái)學(xué)習(xí)下如何對(duì)圖像進(jìn)行特效處理2021-11-11
Python如何使用BeautifulSoup爬取網(wǎng)頁(yè)信息
這篇文章主要介紹了Python如何使用BeautifulSoup爬取網(wǎng)頁(yè)信息,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-11-11
Python自動(dòng)化實(shí)戰(zhàn)之接口請(qǐng)求的實(shí)現(xiàn)
本文為大家重點(diǎn)介紹如何通過(guò) python 編碼來(lái)實(shí)現(xiàn)我們的接口測(cè)試以及通過(guò)Pycharm的實(shí)際應(yīng)用編寫(xiě)一個(gè)簡(jiǎn)單接口測(cè)試,感興趣的可以了解一下2022-05-05

