NewInvestor
NewInvestor

Reputation: 11

Density plot - how to change frequency on x-axis

I created the below code to generate a density plot, however the frequency of the x axis is way too big ie it counts in 2's. However the value of most of my data is less that 1 so I want to be able to change the frequency of the x axis. Is that possible?

my_density_plot <- data.frame(Data = Data)
b <- ggplot(my_density_plot, aes(x=Data))+ labs(title = "Density test", y = 
"Density")
b <- b + stat_density(geom = "line", alpha = 1, colour = "cornflowerblue")
print(b)

Upvotes: 1

Views: 1401

Answers (1)

bob1
bob1

Reputation: 408

Add a line:

scale_x_continuous(breaks = c(#'s, you, want), labels = c(labels, you, want))

Check out the documentation at https://ggplot2.tidyverse.org/reference/scale_continuous.html

Upvotes: 1

Related Questions