簡體   English   中英

使用 swarmplot 生成的 beeswarm plot 中的數據點沒有分散?

[英]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 生成的蜂群圖的圖像 在此處輸入圖像描述

在此處輸入圖像描述

去掉axesaspect=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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM