Axis of histogram, package ggplot2

Hello,
What command I can use in ggplot2 to show all number in the X axis?
And how can I change the axis title position?
I also want to put labels in each column

I am using this command bellow and the packages ggplot2 and hrbrthemes
plot(parametros2$p2, geom = "histogram")
ggplot(parametros2, aes(x = p2)) + geom_histogram(breaks=seq(0, 3, by = 0.08), pad = T,
ylim = c(0,50), by = 5) +
theme_ipsum_ps() +
xlab("p2")+
ylab("Frequência")

image

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

1 Like

The only way I know how to do something like this is to do something like generate the plot first, then add a new x-scale using information taken from the pre-built but not displayed plot.

library(tidyverse)
set.seed(123)
n <- 100
df <- data.frame(x = runif(n, 0, 2)^2)

ggp <- ggplot(df, aes(x = x)) +
    geom_histogram(bins = 17, center = 0, color = "black")
ggp

ggp + scale_x_continuous(breaks = round(ggplot_build(ggp)$data[[1]]$x, 2))

Created on 2020-09-05 by the reprex package (v0.3.0)

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.