一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

腳本之家,腳本語言編程技術(shù)及教程分享平臺(tái)!
分類導(dǎo)航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務(wù)器之家 - 腳本之家 - Python - Matlab、Python為工具解析數(shù)據(jù)可視化之美

Matlab、Python為工具解析數(shù)據(jù)可視化之美

2022-03-02 00:11CaiBirdHu Python

下面介紹一些數(shù)據(jù)可視化的作品(包含部分代碼),主要是地學(xué)領(lǐng)域,可遷移至其他學(xué)科,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧

在我們科研、工作中,將數(shù)據(jù)完美展現(xiàn)出來尤為重要。
數(shù)據(jù)可視化是以數(shù)據(jù)為視角,探索世界。我們真正想要的是 ― 數(shù)據(jù)視覺,以數(shù)據(jù)為工具,以可視化為手段,目的是描述真實(shí),探索世界。
下面介紹一些數(shù)據(jù)可視化的作品(包含部分代碼),主要是地學(xué)領(lǐng)域,可遷移至其他學(xué)科。

 

Example 1 :散點(diǎn)圖、密度圖(Python

import numpy as np
import matplotlib.pyplot as plt

# 創(chuàng)建隨機(jī)數(shù)
n = 100000
x = np.random.randn(n)
y = (1.5 * x) + np.random.randn(n)
fig1 = plt.figure()
plt.plot(x,y,'.r')
plt.xlabel('x')
plt.ylabel('y')
plt.savefig('2D_1V1.png',dpi=600)

nbins = 200
H, xedges, yedges = np.histogram2d(x,y,bins=nbins)
# H needs to be rotated and flipped
H = np.rot90(H)
H = np.flipud(H)
# 將zeros mask
Hmasked = np.ma.masked_where(H==0,H) 
# Plot 2D histogram using pcolor
fig2 = plt.figure()
plt.pcolormesh(xedges,yedges,Hmasked)  
plt.xlabel('x')
plt.ylabel('y')
cbar = plt.colorbar()
cbar.ax.set_ylabel('Counts')
plt.savefig('2D_2V1.png',dpi=600)
plt.show()

Matlab、Python為工具解析數(shù)據(jù)可視化之美

Matlab、Python為工具解析數(shù)據(jù)可視化之美

 

Example 2 :雙Y軸(Python)

import csv
import pandas as pd
import matplotlib.pyplot as plt
from datetime import datetime

data=pd.read_csv('LOBO0010-2020112014010.tsv',sep='\t')
time=data['date [AST]']
sal=data['salinity']
tem=data['temperature [C]']
print(sal)
DAT = []
for row in time:
DAT.append(datetime.strptime(row,"%Y-%m-%d %H:%M:%S"))

#create figure
fig, ax =plt.subplots(1)
# Plot y1 vs x in blue on the left vertical axis.
plt.xlabel("Date [AST]")
plt.ylabel("Temperature [C]", color="b")
plt.tick_params(axis="y", labelcolor="b")
plt.plot(DAT, tem, "b-", linewidth=1)
plt.title("Temperature and Salinity from LOBO (Halifax, Canada)")
fig.autofmt_xdate(rotation=50)

# Plot y2 vs x in red on the right vertical axis.
plt.twinx()
plt.ylabel("Salinity", color="r")
plt.tick_params(axis="y", labelcolor="r")
plt.plot(DAT, sal, "r-", linewidth=1)

#To save your graph
plt.savefig('saltandtemp_V1.png' ,bbox_inches='tight')
plt.show()

Matlab、Python為工具解析數(shù)據(jù)可視化之美

 

Example 3:擬合曲線(Python)

import csv
import numpy as np
import pandas as pd
from datetime import datetime
import matplotlib.pyplot as plt
import scipy.signal as signal

data=pd.read_csv('LOBO0010-20201122130720.tsv',sep='\t')
time=data['date [AST]']
temp=data['temperature [C]']
datestart = datetime.strptime(time[1],"%Y-%m-%d %H:%M:%S")
DATE,decday = [],[]
for row in time:
  daterow = datetime.strptime(row,"%Y-%m-%d %H:%M:%S")
  DATE.append(daterow)
  decday.append((daterow-datestart).total_seconds()/(3600*24))
# First, design the Buterworth filter
N  = 2    # Filter order
Wn = 0.01 # Cutoff frequency
B, A = signal.butter(N, Wn, output='ba')
# Second, apply the filter
tempf = signal.filtfilt(B,A, temp)
# Make plots
fig = plt.figure()
ax1 = fig.add_subplot(211)
plt.plot(decday,temp, 'b-')
plt.plot(decday,tempf, 'r-',linewidth=2)
plt.ylabel("Temperature (oC)")
plt.legend(['Original','Filtered'])
plt.title("Temperature from LOBO (Halifax, Canada)")
ax1.axes.get_xaxis().set_visible(False)

ax1 = fig.add_subplot(212)
plt.plot(decday,temp-tempf, 'b-')
plt.ylabel("Temperature (oC)")
plt.xlabel("Date")
plt.legend(['Residuals'])
plt.savefig('tem_signal_filtering_plot.png', bbox_inches='tight')
plt.show()

Matlab、Python為工具解析數(shù)據(jù)可視化之美

 

Example 4:三維地形(Python)

# This import registers the 3D projection
from mpl_toolkits.mplot3d import Axes3D  
from matplotlib import cbook
from matplotlib import cm
from matplotlib.colors import LightSource
import matplotlib.pyplot as plt
import numpy as np

filename = cbook.get_sample_data('jacksboro_fault_dem.npz', asfileobj=False)
with np.load(filename) as dem:
  z = dem['elevation']
  nrows, ncols = z.shape
  x = np.linspace(dem['xmin'], dem['xmax'], ncols)
  y = np.linspace(dem['ymin'], dem['ymax'], nrows)
x, y = np.meshgrid(x, y)

region = np.s_[5:50, 5:50]
x, y, z = x[region], y[region], z[region]
fig, ax = plt.subplots(subplot_kw=dict(projection='3d'))
ls = LightSource(270, 45)

rgb = ls.shade(z, cmap=cm.gist_earth, vert_exag=0.1, blend_mode='soft')
surf = ax.plot_surface(x, y, z, rstride=1, cstride=1, facecolors=rgb,
                     linewidth=0, antialiased=False, shade=False)
plt.savefig('example4.png',dpi=600, bbox_inches='tight')
plt.show()

Matlab、Python為工具解析數(shù)據(jù)可視化之美

 

Example 5:三維地形,包含投影(Python)

Matlab、Python為工具解析數(shù)據(jù)可視化之美

 

Example 6:切片,多維數(shù)據(jù)同時(shí)展現(xiàn)(Python)

Matlab、Python為工具解析數(shù)據(jù)可視化之美

 

Example 7:SSH GIF 動(dòng)圖展現(xiàn)(Matlab

Matlab、Python為工具解析數(shù)據(jù)可視化之美

 

Example 8:Glider GIF 動(dòng)圖展現(xiàn)(Python)

Matlab、Python為工具解析數(shù)據(jù)可視化之美

 

Example 9:渦度追蹤 GIF 動(dòng)圖展現(xiàn)

Matlab、Python為工具解析數(shù)據(jù)可視化之美

到此這篇關(guān)于數(shù)據(jù)可視化之美 -- 以Matlab、Python為工具的文章就介紹到這了,更多相關(guān)python數(shù)據(jù)可視化之美內(nèi)容請(qǐng)搜索服務(wù)器之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持服務(wù)器之家!

原文鏈接:https://blog.csdn.net/weixin_45492560/article/details/121309333

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 日本一道高清不卡免费 | 99色在线视频 | 国产a一级 | 爽好大快深点一视频 | 无人影院在线播放 | 国产精品99爱免费视频 | 毛片在线看网站 | 免费观看欧美成人h | 曹逼网站 | 国产图片一区 | 成人中文字幕在线观看 | 精品卡1卡2卡三卡免费网站 | 国产亚洲一区二区三区 | 草莓视频网站18勿进 | www.四虎在线| 精品无人乱码一区二区三区 | 亚洲国产婷婷俺也色综合 | 国产精品国产三级在线专区 | 亚洲国产AV一区二区三区四区 | 3x免费高清视频 | 日本又大又硬又粗的视频 | 手机在线免费观看日本推理片 | 99热99re| 亚洲电影成人 成人影院 | 毛片应用| 无限韩国视频免费播放 | 四虎影视库永久在线地址 | 国产男人搡女人免费视频 | 免费叼嘿视频 | 国产欧美精品一区二区三区 | 99爱在线观看精品视频 | 91久久青青草原线免费 | 99av麻豆 | 国产成人精品一区二区不卡 | 日本在线一区二区 | 视频免费观看在线播放高清 | 百合文高h| 亚洲精品tv久久久久久久久久 | 楚乔传第二部全60集免费观看 | 日本免费一区二区三区四区五六区 | 高考录取率1977-2021 |