2
Good morning, everyone. I’m trying to do a histogram with ggplot(), but I’m having a hard time with one detail.
Basically I would like to manually group the data that gets inserted inside each bin of my histogram.
p8 <- ggplot(TGL_Filtered , aes(x = TP)) +
geom_histogram(aes(y = ..count..), binwidth = 2.5,
colour = barlines, fill = barfill) +
scale_x_continuous(name = "Tp (s)",
breaks = seq(0, 25, 5),
limits=c(0,25)) +
scale_y_continuous(name = "Porcentagem %") +
ggtitle("Período de Pico") +
theme_bw() +
theme(axis.line = element_line(size=1, colour = "black"),
panel.grid.major = element_line(colour = "#d3d3d3",linetype = "dashed"),
panel.grid.minor = element_blank(),
panel.border = element_blank(), panel.background = element_blank(),
plot.title = element_text(size = 14, family = "Tahoma", face = "bold"),
text=element_text(family="Tahoma"),
axis.text.x=element_text(colour="black", size = 9),
axis.text.y=element_text(colour="black", size = 9))
p8
I’d like the bars to stand for intervals I determine. EX instead of appearing number 2, 4, 6 below a bar, I would like it to appear [2 to 4), [4 to 6), [6 to 8). and
Welcome to Stackoverflow! Unfortunately, this question cannot be reproduced by anyone trying to answer it. Please, take a look at this link and see how to ask a reproducible question in R. So, people who wish to help you will be able to do this in the best possible way.
– Marcus Nunes
Hello Rodrigo Rsilva, when applying the Histogram it is already defined by statistical calculations. From the data sample, amplitude calculation and class analysis. The same happens with the boxplot chart, they already have defined rules for statistical analysis and as much as we would like to change, both
hist()
how muchboxplot()
they are already defined in the most ideal way to help us interpret our data.– Izak Mandrak
Yeah, I think that’s right. , that’s why I’d like to configure the grouping of the data myself.
– Rodrigo Rsilva