Set Origin of ggplot2 Plot Axes to Zero in R (Example) | Force to Start at 0 | scale_x_continuous

preview_player
Показать описание
R code of this video:

y = 1:6)

library("ggplot2") # Load ggplot2

ggp <- ggplot(data, aes(x, y)) + # ggplot2 plot with default axis
geom_point()
ggp # Draw default ggplot2 plot

ggp + # Set origin of axes to zero
scale_x_continuous(expand = c(0, 0), limits = c(0, 7)) +
scale_y_continuous(expand = c(0, 0), limits = c(0, 7))

Follow me on Social Media:
Рекомендации по теме
Комментарии
Автор

Finally I learned how to do that, thanks a lot! :)

fabiodagostino
Автор

Hey, I have a question about the results from console and Rmarkdown. Why could you get a different accuracy in your console than from your Rmarkdown, even when you run the same script? Could you explain that?

brogames
welcome to shbcf.ru