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

Bubble chart

A bubble plot is a manifestation of the scatter plot where each data point on the graph is shown as a bubble. Each bubble can be illustrated with a different color, size, and appearance.

Let 's continue using the Iris dataset to get a bubble plot. Here, the important thing to note is that we are still going to use the plt.scatter method to draw a bubble chart:

# Load the Iris dataset
df = sns.load_dataset('iris')

df['species'] = df['species'].map({'setosa': 0, "versicolor": 1, "virginica": 2})

# Create bubble plot
plt.scatter(df.petal_length, df.petal_width,
s=50*df.petal_length*df.petal_width,
c=df.species,
alpha=0.3
)

# Create labels for axises
plt.xlabel('Septal Length')
plt.ylabel('Petal length')
plt.show()

The bubble chart generated by the preceding code is as follows:

Can you interpret the results? Well, it is not clear from the graph which color represents which species of Iris. But we can clearly see three different clusters, which clearly indicates for each specific species or cluster there is a relationship between Petal Length and Petal Width

主站蜘蛛池模板: 苍溪县| 保靖县| 宜黄县| 鄂伦春自治旗| 靖远县| 新蔡县| 沾化县| 威宁| 沽源县| 金乡县| 文安县| 宿松县| 高尔夫| 和政县| 巍山| 砚山县| 吕梁市| 黄山市| 昆山市| 鹤山市| 龙游县| 彭泽县| 巨鹿县| 屯昌县| 西吉县| 思南县| 南宫市| 青冈县| 甘孜县| 岢岚县| 木里| 耿马| 凤山县| 策勒县| 隆化县| 富平县| 奉新县| 龙泉市| 梅州市| 阜新市| 利川市|