Since my last question is running into dead ends, guess I will try it this way:
How do I label ONLY the top of the barplot for each condition? It needs to label both the count and the intensity (i.e. x and y-axis intersection). And to make clear, not label as in place a little dot, label as in print the information exactly as it corresponds to the count and intensity.
I feel like I have googled every possible combination of words to get this answer and still cannot get it to work. Proof? I searched mode functions here, here, and graphical approaches here and here.
My plot looks like this (with my own data), without the labels of the peaks:
With the code to produce it:
#demo data:
set.seed(1234)
library(tidyverse)
library(fs)
n = 100000
silence = factor(c("sil1", "sil2", "sil3", "sil4", "sil5"))
treat = factor(c("con", "uos", "uos+wnt5a", "wnt5a"))
df <- expand.grid(silence = silence, treat = treat)
df <- data.frame(
silence = rep(df$silence, each = 1000),
treat = rep(df$treat, each = 1000)
)
df$intensity <- rgamma(nrow(df), shape = match(df$silence, unique(df$silence)),
scale = match(df$treat, unique(df$treat)))
p <-
df %>%
ggplot() +
aes(x = intensity, fill = treat) +
geom_histogram(bins = 100L, alpha = 0.75, position = "identity") +
scale_fill_viridis_d(option = "plasma") +
theme_minimal() +
labs(x = "Intensity", y = "No. of intensities", title = "F1 Silencing", fill = "Treatment:") +
facet_wrap(vars(silence))
So ideally I would have a little dot on the highest point of within treatment condition and each pane that labels 1) the count corresponding to that intensity. Example: red dot with the corresponding count and intensity at the peak of the peach (UOS+wnt5a) graph.