python画气泡标尺图


在进行实验结果分析的时候,气泡标尺图能非常清晰对不同的结果进行多维度的比较,特别是在深度学习模型大小和精度进行比较的时候非常合适使用,以下是几个例子。

渐变气泡图

import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd

data = pd.DataFrame({
    'Model Size (MB)': [251, 218, 261, 280, 221],
    'Accuracy': [0.85, 0.88, 0.87, 0.91, 0.83],
    'Model Name': ['Resnet', 'Unet', 'Googlenet', 'Deeplabv3', 'Pspnet']
})

# Create a bubble plot with larger circle sizes for different accuracies and a different colormap
plt.figure(figsize=(10, 6))
plot = sns.scatterplot(data=data, x='Model Size (MB)', y='Accuracy', size='Accuracy', hue='Accuracy', sizes=(100, 1000), cmap='viridis')
plt.title('Bubble Plot of Model Size vs. Accuracy in Deep Learning')
plt.xlabel('Model Size (MB)')
plt.ylabel('Accuracy')

# Customize the legend and move it inside the plot to the upper left corner
plt.legend(title='Accuracy')
plt.gca().legend(loc='upper left', bbox_to_anchor=(0.02, 0.98))

# Add model names near the circles
for line in range(0, data.shape[0]):
    plot.text(data['Model Size (MB)'][line], data['Accuracy'][line], data['Model Name'][line], horizontalalignment='left', size='medium', color='black', weight='semibold')

# Adjust X-axis tick spacing
plt.xticks([200, 220, 240, 260, 280, 300])

plt.show()

示例图:
请添加图片描述

彩色气泡图

import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd

data = pd.DataFrame({
    'Model Size (MB)': [251, 218, 261, 280, 221],
    'Accuracy': [0.85, 0.88, 0.87, 0.91, 0.83],
    'Model Name': ['Resnet', 'Unet', 'Googlenet', 'Deeplabv3', 'Pspnet']
})

# Define a bright and colorful color palette
bright_palette = sns.color_palette("husl", as_cmap=True)

# Create a bubble plot with larger circle sizes for different accuracies and the defined color palette
plt.figure(figsize=(10, 6))
plot = sns.scatterplot(data=data, x='Model Size (MB)', y='Accuracy', size='Accuracy', hue='Accuracy', sizes=(100, 1000), palette=bright_palette)
plt.title('Bubble Plot of Model Size vs. Accuracy in Deep Learning')
plt.xlabel('Model Size (MB)')
plt.ylabel('Accuracy')

# Customize the legend and move it inside the plot to the upper left corner
plt.legend(title='Accuracy')
plt.gca().legend(loc='upper left', bbox_to_anchor=(0.02, 0.98))

# Add model names near the circles
for line in range(0, data.shape[0]):
    plot.text(data['Model Size (MB)'][line], data['Accuracy'][line], data['Model Name'][line], horizontalalignment='left', size='medium', color='black', weight='semibold')

# Adjust X-axis tick spacing
plt.xticks([200, 220, 240, 260, 280, 300])

plt.show()

示例图:
请添加图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

凡心curry

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值