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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python可视化水平双向箭头_python数据可视化第二弹

發布時間:2023/12/3 python 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python可视化水平双向箭头_python数据可视化第二弹 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

代碼模板:

最前面

importpandas as pd

pd.plotting.register_matplotlib_converters()importmatplotlib.pyplot as plt%matplotlib inlineimportseaborn as snsprint("Setup Complete")

View Code

一、折線圖Line charts

plt.figure(figsize=(14,6))#Add title

plt.title("Daily Global Streams of Popular Songs in 2017-2018")#Line chart showing daily global streams of 'Shape of You'

sns.lineplot(data=spotify_data['Shape of You'], label="Shape of You")#Line chart showing daily global streams of 'Despacito'

sns.lineplot(data=spotify_data['Despacito'], label="Despacito")#Add label for horizontal axis

plt.xlabel("Date")#選擇需要的變量輸出

or

#Set the width and height of the figure

plt.figure(figsize=(14,6))#Add title

plt.title("Daily Global Streams of Popular Songs in 2017-2018")#Line chart showing daily global streams of each song

sns.lineplot(data=spotify_data)#所有變量輸出

View Code

二、條狀圖和熱力圖Bar charts and heatmaps

#Set the width and height of the figure

plt.figure(figsize=(10,6))#Add title

plt.title("Average Arrival Delay for Spirit Airlines Flights, by Month")#Bar chart showing average arrival delay for Spirit Airlines flights by month

sns.barplot(x=flight_data.index, y=flight_data['NK'])#Add label for vertical axis

plt.ylabel("Arrival delay (in minutes)")

plt.xlabel("")

View Code

#Set the width and height of the figure

plt.figure(figsize=(14,7))#Add title

plt.title("Average Arrival Delay for Each Airline, by Month")#Heatmap showing average arrival delay for each airline by month

sns.heatmap(data=flight_data, annot=True)

當annot為True時,在heatmap中每個方格寫入數據#Add label for horizontal axis

plt.xlabel("Airline")

plt.ylabel("")

View Code

三、散點圖Scatter plots:

1. Create a scatter plot

sns.scatterplot(x=insurance_data['bmi'], y=insurance_data['charges'])

View Code

2.加入趨勢線a regression line

sns.regplot(x=insurance_data['bmi'], y=insurance_data['charges'])

View Code

3、顏色編碼的散點圖Color-coded scatter plots

sns.scatterplot(x=insurance_data['bmi'], y=insurance_data['charges'], hue=insurance_data['smoker'])

View Code

4、 兩條趨勢線two regression lines

sns.lmplot(x="bmi", y="charges", hue="smoker", data=insurance_data)

View Code

5、分類散點圖a categorical scatter plot

sns.swarmplot(x=candy_data['chocolate'],

y=candy_data['winpercent'])

View Code

四、直方圖histograms

#Histogram

sns.distplot(a=iris_data['Petal Length (cm)'], kde=False)

View Code

五、密度圖density plots

1、核心密度圖kernel density estimate (KDE) plot

#KDE plot

sns.kdeplot(data=iris_data['Petal Length (cm)'], shade=True)

View Code

2、二維KDE圖two-dimensional (2D) KDE plot

#2D KDE plot

sns.jointplot(x=iris_data['Petal Length (cm)'], y=iris_data['Sepal Width (cm)'], kind="kde")

View Code

六、彩色圖Color-coded plots

#Histograms for each species

sns.distplot(a=iris_set_data['Petal Length (cm)'], label="Iris-setosa", kde=False)

sns.distplot(a=iris_ver_data['Petal Length (cm)'], label="Iris-versicolor", kde=False)

sns.distplot(a=iris_vir_data['Petal Length (cm)'], label="Iris-virginica", kde=False)#Add title

plt.title("Histogram of Petal Lengths, by Species")#Force legend to appear

plt.legend()

View Code

#KDE plots for each species

sns.kdeplot(data=iris_set_data['Petal Length (cm)'], label="Iris-setosa", shade=True)

sns.kdeplot(data=iris_ver_data['Petal Length (cm)'], label="Iris-versicolor", shade=True)

sns.kdeplot(data=iris_vir_data['Petal Length (cm)'], label="Iris-virginica", shade=True)#Add title

plt.title("Distribution of Petal Lengths, by Species")

View Code

總結:

以上圖形可分為三類:

趨勢Trend——即為變化的模式

- sns.lineplot - 折線圖最適合顯示一段時間內的趨勢,多條折線可用于顯示多個組中的趨勢

關系Relationship——反映數據中變量之間的關系

-sns.barplot - 柱狀圖對于比較不同組對應的數量很有用

-sns.heatmap - 熱圖可以用來在數字表中找到彩色編碼的模式

-sns.scatterplot - 散點圖表示兩個連續變量之間的關系;如果用顏色編碼,我們還可以顯示與第三個分類變量的關系

-sns.regplot - 在散點圖中包含一條回歸線可以更容易地看到兩個變量之間的任何線性關系.

-sns.lmplot - 如果散點圖包含多個顏色編碼的組,則此命令對于繪制多個回歸線非常有用

-sns.swarmplot - 分類散點圖顯示了連續變量和分類變量之間的關系.

分布Distribution——可視化分布來顯示變量中可能出現的值,以及它們出現的可能性

-sns.distplot - 直方圖表示單個數值變量的分布

-sns.kdeplot - KDE圖(或2D KDE圖)顯示了單個數值變量(或兩個數值變量)的估計的、平滑的分布。

-sns.jointplot - 此命令對于同時顯示2D KDE繪圖和每個單獨變量的相應KDE繪圖非常有用。

(引用于https://blog.csdn.net/freja110/article/details/104856712)

總結

以上是生活随笔為你收集整理的python可视化水平双向箭头_python数据可视化第二弹的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。