import matplotlib.pyplot as plt
import numpy as np
# data
x=["IEEE", "Elsevier", "Others"]
y=[7, 6, 2]
import seaborn as sns
plt.legend()
plt.scatter(x, y, s=300, c="blue", alpha=0.4, linewidth=3)
plt.ylabel("No. of Papers")
plt.figure(figsize=(10, 4))
我想画一张图,如图所示。我不知道如何为期刊和会议类别提供数据。(目前,我只包括一个)。此外,我不知道如何为每个类别添加不同的颜色。
您可以针对您的问题尝试此代码段
-我修改了您的数据格式,建议您使用熊猫作为 数据可视化。
-我又添加了一个字段,以便更有效地可视化数据。
如何创建气泡大小正确且无重叠的图形
Seaborn ^{} 和^{} (或} 的
sns.catplot(kind=strip or kind=swarm)
)提供了方便的dodge
参数,防止气泡重叠。唯一的缺点是size
参数将单个大小应用于所有气泡,而sizes
参数(在另一个答案中使用)在这里没有用处。它们不像^{s
和size
参数那样工作。因此,生成绘图后,必须编辑每个气泡的大小:或者,您可以将
scatterplot
与方便的s
参数(或size
)一起使用,然后编辑气泡之间的空间,以重现缺少的dodge
参数的效果(注意x_jitter
参数似乎没有效果)。下面是一个示例,使用与以前相同的数据,但没有所有额外的格式:作为一个旁注,我建议您考虑其他类型的数据。分组条形图:
或balloon plot(又称分类气泡图):
为什么?在气泡图中,计数使用两个视觉属性显示,i)y坐标位置和ii)气泡大小。其中只有一个是真正必要的
相关问题 更多 >
编程相关推荐