- Hands-On Exploratory Data Analysis with Python
- Suresh Kumar Mukhiya Usman Ahmed
- 167字
- 2021-06-24 16:44:52
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.
推薦閱讀
- Puppet 4 Essentials(Second Edition)
- Learn Blockchain Programming with JavaScript
- Mastering RabbitMQ
- 體驗(yàn)設(shè)計(jì)原理:行為、情感和細(xì)節(jié)
- Hands-On Data Structures and Algorithms with JavaScript
- C和C++安全編碼(原書第2版)
- Python神經(jīng)網(wǎng)絡(luò)項(xiàng)目實(shí)戰(zhàn)
- 微服務(wù)從小白到專家:Spring Cloud和Kubernetes實(shí)戰(zhàn)
- C語言從入門到精通
- Scala for Machine Learning(Second Edition)
- OpenCV 3 Blueprints
- MySQL 8從零開始學(xué)(視頻教學(xué)版)
- Python預(yù)測(cè)分析與機(jī)器學(xué)習(xí)
- Learning TypeScript
- Mastering Machine Learning with scikit-learn