官术网_书友最值得收藏!

Scatter plot using seaborn

A scatter plot can also be generated using the seaborn library. Seaborn makes the graph visually better. We can illustrate the relationship between x and y for distinct subsets of the data by utilizing the size, style, and hue parameters of the scatter plot in seaborn.

Get more detailed information about the parameters from seaborn's documentation website: https://seaborn.pydata.org/generated/seaborn.scatterplot.html.

Now, let's load the Iris dataset:

df = sns.load_dataset('iris')

df['species'] = df['species'].map({'setosa': 0, "versicolor": 1, "virginica": 2})
sns.scatterplot(x=df["sepal_length"], y=df["sepal_width"], hue=df.species, data=df)

The scatter plot generated from the preceding code is as follows:

In the preceding plot, we can clearly see there are three species of flowers indicated by three distinct colors. It is more clear from the diagram how different specifies of flowers vary in terms of the sepal width and the length. 

主站蜘蛛池模板: 嵊泗县| 和田市| 集安市| 齐齐哈尔市| 南陵县| 六安市| 沙雅县| 岳西县| 郁南县| 会理县| 呼伦贝尔市| 栖霞市| 汕头市| 土默特右旗| 喀什市| 古浪县| 孟州市| 银川市| 临夏市| 祁连县| 连南| 台安县| 张掖市| 青阳县| 吴忠市| 浮山县| 资兴市| 大化| 凌海市| 上蔡县| 西昌市| 德惠市| 灵宝市| 蒲江县| 长子县| 闻喜县| 通化县| 舒兰市| 法库县| 临夏县| 色达县|