Violin Plot shows additional data points

48 views Asked by At

This is my first post, so I hope to mention everything needed to hopefully receive an answer.

My violin plot shows more data points than given in the data frame I use for it.

I created an R script to present my data about pollinator density (Sum_num) in relation to transect round (Transect_nr.y) and honeybee hives (Hives) in a Violin Plot. The plot looks like this:

Violin Plot Pollinator Density per Transect Round

This is the script I created for the plot:

ggplot(all_combinations, aes(x = PollinatorType, y = Sum_num, fill = PollinatorType)) +
  geom_violin(trim = FALSE) +
  geom_jitter(width = 0.2, alpha = 1.0, show.legend = FALSE) +
  geom_boxplot(width=0.165, color="black", alpha=0.7) +
  labs(x = "Pollinator Type", y = "Density of Pollinators per 150 m^2", fill = "Pollinator Type") +
  ggtitle("Density of Honeybees and Wild Pollinators per Transect Round") +
  facet_grid(Hives ~ factor(Transect_nr.y, levels=c('1','2','3','4'))) +
  theme_minimal() +
  theme(axis.text.x = element_blank(),  # Remove x-axis labels
        axis.title.x = element_blank(), # Remove x-axis title
        legend.position = "bottom")

Looking at my data frame used for this graph, I noticed that additional data points are shown in the graph which are not present in the data frame. This is the case for all the lighter black dots on top of the violin (e.g., Transect round 2, no hives, honeybees --> dot at ~185). Here is an excerpt of the data frame in which you can see that for the mentioned example, there should actually only be 7 data points, however the graph displays 8.

Data frame excerpt

Why is that? Could there be something wrong with my script for the violin plot?

Thanks in advance! Klara

0

There are 0 answers