亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Python中seaborn庫之countplot的數(shù)據(jù)可視化使用

 更新時間:2021年06月11日 10:24:09   作者:cymx66688  
在Python數(shù)據(jù)可視化中,seaborn較好的提供了圖形的一些可視化功效。本文詳細的介紹了Python中seaborn庫之countplot的數(shù)據(jù)可視化使用,感興趣的可以了解一下

在Python數(shù)據(jù)可視化中,seaborn較好的提供了圖形的一些可視化功效。

seaborn官方文檔見鏈接:http://seaborn.pydata.org/api.html

countplot是seaborn庫中分類圖的一種,作用是使用條形顯示每個分箱器中的觀察計數(shù)。接下來,對seaborn中的countplot方法進行詳細的一個講解,希望可以幫助到剛?cè)腴T的同行。

導(dǎo)入seaborn庫

import seaborn as sns

使用countplot

sns.countplot()

countplot方法中必須要x或者y參數(shù),不然就報錯。

官方給出的countplot方法及參數(shù):

sns.countplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, orient=None, color=None, palette=None, saturation=0.75, dodge=True, ax=None, **kwargs)

下面講解countplot方法中的每一個參數(shù)。以泰坦尼克號為例。

原始數(shù)據(jù)如下:

sns.set(style='darkgrid')
titanic = sns.load_dataset('titanic')
titanic.head()

x, y, hue : names of variables in ``data`` or vector data, optional. Inputs for plotting long-form data. See examples for interpretation.

第一種方式

x: x軸上的條形圖,以x標簽劃分統(tǒng)計個數(shù)

y: y軸上的條形圖,以y標簽劃分統(tǒng)計個數(shù)

hue: 在x或y標簽劃分的同時,再以hue標簽劃分統(tǒng)計個數(shù)

sns.countplot(x="class", data=titanic)

sns.countplot(y="class", data=titanic)

sns.countplot(x="class", hue="who", data=titanic)

第二種方法

x: x軸上的條形圖,直接為series數(shù)據(jù)

y: y軸上的條形圖,直接為series數(shù)據(jù)

sns.countplot(x=titanic['class'])

sns.countplot(y=titanic['class'])

data : DataFrame, array, or list of arrays, optional. Dataset for plotting.
If ``x`` and ``y`` are absent, this is interpreted as wide-form. Otherwise it is expected to be long-form.

data: DataFrame或array或array列表,用于繪圖的數(shù)據(jù)集,x或y缺失時,data參數(shù)為數(shù)據(jù)集,同時x或y不可缺少,必須要有其中一個。

sns.countplot(x='class', data=titanic)

order, hue_order : lists of strings, optional.Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
order, hue_order分別是對x或y的字段排序,hue的字段排序。排序的方式為列表。

sns.countplot(x='class', data=titanic, order=['Third', 'Second', 'First'])

sns.countplot(x='class', hue='who', data=titanic, hue_order=['woman', 'man', 'child'])

orient : "v" | "h", optional
Orientation of the plot (vertical or horizontal). This is usually
inferred from the dtype of the input variables, but can be used to
specify when the "categorical" variable is a numeric or when plotting
wide-form data.
強制定向,v:豎直方向;h:水平方向,具體實例未知。

color : matplotlib color, optional
Color for all of the elements, or seed for a gradient palette.

palette : palette name, list, or dict, optional.Colors to use for the different levels of the ``hue`` variable.
Should be something that can be interpreted by :func:`color_palette`, or a dictionary mapping hue levels to matplotlib colors.

palette:使用不同的調(diào)色板

sns.countplot(x="who", data=titanic, palette="Set3")

ax : matplotlib Axes, optional
Axes object to draw the plot onto, otherwise uses the current Axes.

ax用來指定坐標系。

fig, ax = plt.subplots(1, 2, figsize=(10, 5))
sns.countplot(x='class', data=titanic, ax=ax[0])
sns.countplot(y='class', data=titanic, ax=ax[1])

到此這篇關(guān)于Python中seaborn庫之countplot的數(shù)據(jù)可視化使用的文章就介紹到這了,更多相關(guān)Python seaborn庫countplot內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 解決導(dǎo)入django_filters不成功問題No module named ''django_filter''

    解決導(dǎo)入django_filters不成功問題No module named ''django_filter''

    這篇文章主要介紹了解決導(dǎo)入django_filters不成功問題No module named 'django_filter',具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-07-07
  • Python中的文本相似度的計算方法總結(jié)

    Python中的文本相似度的計算方法總結(jié)

    在自然語言處理(NLP)領(lǐng)域,文本相似度計算是一個常見的任務(wù),本文為大家整理了Python中的文本相似度常見計算方法,希望對大家有所幫助
    2023-05-05
  • django 使用內(nèi)置messages的操作

    django 使用內(nèi)置messages的操作

    這篇文章主要介紹了django 使用內(nèi)置messages的操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-04-04
  • python3中利用filter函數(shù)輸出小于某個數(shù)的所有回文數(shù)實例

    python3中利用filter函數(shù)輸出小于某個數(shù)的所有回文數(shù)實例

    今天小編就為大家分享一篇 python3中利用filter函數(shù)輸出小于某個數(shù)的所有回文數(shù)實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-11-11
  • Python常用庫推薦

    Python常用庫推薦

    本文給大家推薦的是在Python學習使用中經(jīng)常需要用到的第三方庫和工具,非常的實用,有需要的小伙伴可以參考下
    2016-12-12
  • 根據(jù)DataFrame某一列的值來選擇具體的某一行方法

    根據(jù)DataFrame某一列的值來選擇具體的某一行方法

    今天小編就為大家分享一篇根據(jù)DataFrame某一列的值來選擇具體的某一行方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-07-07
  • Python圖形驗證碼識別教程詳解

    Python圖形驗證碼識別教程詳解

    這篇文章主要介紹了Python圖形驗證碼識別,目前,許多網(wǎng)站采取各種各樣的措施來反爬蟲,其中一個措施便是使用驗證碼。隨著技術(shù)的發(fā)展,驗證碼的花樣越來越多。驗證碼最初是幾個數(shù)字組合的簡單的圖形驗證碼,后來加入了英文字母和混淆曲線
    2023-02-02
  • Python3連接Mysql8.0遇到的問題及處理步驟

    Python3連接Mysql8.0遇到的問題及處理步驟

    最近在使用Python開發(fā)系統(tǒng),需連接mysql數(shù)據(jù)庫,我用的是Python3連接MySQL8.0,其中老是報錯,怎么解決這個問題呢,下面小編給大家?guī)砹薖ython3連接Mysql8.0遇到的問題及處理步驟,需要的朋友參考下吧
    2020-02-02
  • Python?中的json常見用法實例詳解

    Python?中的json常見用法實例詳解

    這篇文章主要介紹了Python?中的json常見用法,本文結(jié)合實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-12-12
  • python調(diào)用攝像頭的示例代碼

    python調(diào)用攝像頭的示例代碼

    這篇文章主要介紹了python調(diào)用攝像頭的示例代碼,幫助大家更好的理解和使用python,感興趣的朋友可以了解下
    2020-09-09

最新評論