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

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. 

主站蜘蛛池模板: 沾化县| 淮南市| 昌黎县| 云梦县| 综艺| 吉安县| 越西县| 库伦旗| 连城县| 丹江口市| 浦江县| 武冈市| 综艺| 基隆市| 长寿区| 托克逊县| 全椒县| 张家界市| 莱西市| 兰坪| 班戈县| 呈贡县| 江达县| 上高县| 宁夏| 沙田区| 四子王旗| 五峰| 长沙县| 绥中县| 喀什市| 许昌市| 大宁县| 高邑县| 金溪县| 盐津县| 资源县| 西贡区| 棋牌| 方城县| 龙山县|