In the below code, when plotting a beeswarm plot using a swarmplot function, I am observing that the data points are not getting scattered in data set 2. But if I change the data set to data set 1, the data points are getting scattered very well. I need that even with the data set 2, the points should be scattered very well. I have tried even by changing the scatter size but to no result. Can somebody help in figuring this out??
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()
I am attaching the images of the beeswarm plots produced using the data sets 1 and data sets 2 enter image description here
Get rid of the aspect=1
flag for axes
so that line reads
axes = fig.add_subplot(1, 1, 1)
Alternatively, you can avoid the subplot jargon altogether unless you intend on adding more subplots to this figure.
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()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.