=Size, fill=Sample)) +
ggplot(df, aes(x
= 100, alpha=.8, color='grey40') +
geom_histogram(bins # scale_x_log10() +
="Count", x="Size [µm]") +
labs(y# coord_cartesian(xlim = c(0.5,120)) +
= 16) + theme(axis.text.y = element_blank()) +
theme_light(base_size ~Sample) +
facet_wrap(= "none") +
theme(legend.position
#Force the y-axis to start at zero
= c(0, NA), limits = c(0,150)) +
scale_y_continuous(expand #Apply a logarithmic scale to the x-axis and set the numbers for the scale
= c(1,10,100), limits = c(.5,200)) +
scale_x_log10(breaks #Remove minor gridlines
= element_blank()) +
theme(panel.grid.minor #Add ticks to the bottom, outside
="b", outside = TRUE) +
annotation_logticks(sides#Give a little more space to the log-ticks by adding margin to the top of the x-axis text
= element_text(margin = margin(t=8))) +
theme(axis.text.x #Needed to see the tcks outside the plot panel
= "off") coord_cartesian(clip
Summarizing the size of cells
Joachim Goedhart
Loading the data from the Google sheet and cleaning it:
The tidy data sheet df
is used as an input for the plot that shows the distribution:
In [1]:
The size data of the Cells is selected and used to plot the distributions as a violin plot per group. The median value is indicated as a black dot:
In [2]:
<- df %>% filter(Sample =="Cell")
df_cell
<- ggplot(df_cell, aes(x=Group, y=Size, fill=Group))
p
<- p + geom_violin() + stat_summary(fun = median, geom = "point")
p
<- p + scale_y_log10()
p
<- p + labs(x="Group", y="Size [µm]")
p <- p + coord_cartesian(ylim = c(0.5,200))
p
<- p + theme_light(base_size = 16)
p <- p + theme(legend.position = "none")
p
p