欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Matlab、Python為工具解析數據可視化之美

 更新時間:2021年11月16日 14:45:23   作者:CaiBirdHu  
下面介紹一些數據可視化的作品(包含部分代碼),主要是地學領域,可遷移至其他學科,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友參考下吧

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

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

import numpy as np
import matplotlib.pyplot as plt

# 創(chuàng)建隨機數
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()

example-figure

在這里插入圖片描述

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()

在這里插入圖片描述

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()

在這里插入圖片描述

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()

在這里插入圖片描述

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

在這里插入圖片描述

Example 6:切片,多維數據同時展現(Python)

在這里插入圖片描述

Example 7:SSH GIF 動圖展現(Matlab)

在這里插入圖片描述

Example 8:Glider GIF 動圖展現(Python)

在這里插入圖片描述

Example 9:渦度追蹤 GIF 動圖展現

在這里插入圖片描述

到此這篇關于數據可視化之美 -- 以Matlab、Python為工具的文章就介紹到這了,更多相關python數據可視化之美內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • Python實現快速多線程ping的方法

    Python實現快速多線程ping的方法

    這篇文章主要介紹了Python實現快速多線程ping的方法,實例分析了Python多線程及ICMP數據包的發(fā)送技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-07-07
  • Python使用描述符實現屬性類型檢查的案例解析

    Python使用描述符實現屬性類型檢查的案例解析

    這篇文章主要介紹了Python使用描述符實現屬性類型檢查,實例屬性就是在一個類中將另一個類的實例作為該類的一個數屬性,本文通過代碼演示給大家介紹的非常詳細,需要的朋友可以參考下
    2022-05-05
  • Python pkg_resources模塊動態(tài)加載插件實例分析

    Python pkg_resources模塊動態(tài)加載插件實例分析

    當編寫應用軟件時,我們通常希望程序具有一定的擴展性,額外的功能——甚至所有非核心的功能,都能通過插件實現,具有可插拔性。特別是使用 Python 編寫的程序,由于語言本身的動態(tài)特性,為我們的插件方案提供了很多種實現方式
    2022-08-08
  • opencv實現圖像幾何變換

    opencv實現圖像幾何變換

    這篇文章主要為大家詳細介紹了opencv實現圖像幾何變換,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-03-03
  • Django框架視圖介紹與使用詳解

    Django框架視圖介紹與使用詳解

    這篇文章主要介紹了Django框架視圖介紹與使用,結合實例形式分析了Django框架視圖的功能、配置、使用方法及相關操作注意事項,需要的朋友可以參考下
    2019-07-07
  • python 實現將文件或文件夾用相對路徑打包為 tar.gz 文件的方法

    python 實現將文件或文件夾用相對路徑打包為 tar.gz 文件的方法

    今天小編就為大家分享一篇python 實現將文件或文件夾用相對路徑打包為 tar.gz 文件的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-06-06
  • python實現圖像邊緣檢測

    python實現圖像邊緣檢測

    這篇文章主要為大家詳細介紹了python實現圖像邊緣檢測,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-08-08
  • python FTP批量下載/刪除/上傳實例

    python FTP批量下載/刪除/上傳實例

    今天小編就為大家分享一篇python FTP批量下載/刪除/上傳實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-12-12
  • Python中yield關鍵字及與return的區(qū)別詳解

    Python中yield關鍵字及與return的區(qū)別詳解

    這篇文章主要介紹了Python中yield關鍵字及與return的區(qū)別詳解,帶有 yield 的函數在 Python 中被稱之為 generator生成器,比如列表所有數據都在內存中,如果有海量數據的話將會非常耗內存,想要得到龐大的數據,又想讓它占用空間少,那就用生成器,需要的朋友可以參考下
    2023-08-08
  • Python Jupyter Notebook顯示行數問題的解決

    Python Jupyter Notebook顯示行數問題的解決

    這篇文章主要介紹了Python Jupyter Notebook顯示行數問題的解決方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-02-02

最新評論