[英]The data points in the beeswarm plot produced using swarmplot are not getting scattered?
在下面的代码中,当使用 swarmplot function 绘制 beeswarm plot 时,我观察到数据点并没有分散在数据集 2 中。但是如果我将数据集更改为数据集 1,数据点会变得非常分散出色地。 我需要即使使用数据集 2,点也应该很好地分散。 我什至尝试通过更改散点大小但没有结果。 有人可以帮助解决这个问题吗?
import matplotlib.pyplot as plt
import numpy as np
import seaborn
# Making beeswarm plot
A=np.array([0.02,0.02,0.02,0.04,0.04,0.05,0.05,0.05,0.05,0.05,0.09,0.09,0.09,0.09,0.09,0.1,0.1,0.1,0.1,0.8,0.8,0.8,0.8]) # data set 1
#A=np.array([20,20,20,20,50,50,50,35,35,35,45,45,58,58,58,58,69,69,69,63,63,63,36,63,77,78,80,80,80,80]) # data set 2
data = A
x_labels = " Depth (Microns)"
y_labels = " Diameter (Microns)"
seaborn.set(color_codes=True)
fig = plt.figure(figsize=(16, 16))
axes = fig.add_subplot(1, 1, 1, aspect=1)
# add title to plot
plt.title("Beeswarm Distribution Plots of Swept Droplet Diameters")
# plot data on swarmplot
seaborn.swarmplot(data=data, color="blue", size=8)
# y-axis label
axes.set(ylabel=y_labels)
axes.set(xlabel=x_labels)
axes.set_xticklabels(['200'])
plt.show()
我附上了使用数据集 1 和数据集 2 生成的蜂群图的图像 在此处输入图像描述
去掉axes
的aspect=1
标志,以便行读取
axes = fig.add_subplot(1, 1, 1)
或者,您可以完全避免使用子图行话,除非您打算在此图中添加更多子图。
import matplotlib.pyplot as plt
import numpy as np
import seaborn
# Making beeswarm plot
# A=np.array([0.02,0.02,0.02,0.04,0.04,0.05,0.05,0.05,0.05,0.05,0.09,0.09,0.09,0.09,0.09,0.1,0.1,0.1,0.1,0.8,0.8,0.8,0.8]) # data set 1
A=np.array([20,20,20,20,50,50,50,35,35,35,45,45,58,58,58,58,69,69,69,63,63,63,36,63,77,78,80,80,80,80]) # data set 2
data = A
x_labels = " Depth (Microns)"
y_labels = " Diameter (Microns)"
seaborn.set(color_codes=True)
fig = plt.figure(figsize=(16, 16))
# add title to plot
plt.title("Beeswarm Distribution Plots of Swept Droplet Diameters")
# plot data on swarmplot
seaborn.swarmplot(data=data, color="blue", size=8)
# y-axis label
plt.ylabel(y_labels)
plt.xlabel(x_labels)
plt.xticks(labels=['200'], ticks=[0])
plt.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.