Set Axis Breaks of ggplot2 Plot in R (3 Examples) | Specify Tick Marks of Graph | scale_x_continuous

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

y = c(4, 6, 8, 1, 5, 3))

library("ggplot2")

ggp <- ggplot(data, aes(x, y)) + # Create default ggplot2 plot
geom_line()
ggp # Draw default ggplot2 plot

ggp + # Manually specify x-axis ticks
scale_x_continuous(breaks = c(2, 3, 5))

ggp + # Manually specify y-axis ticks
scale_y_continuous(breaks = c(2, 3, 5))

ggp + # Manually specify sequence of x-axis ticks
scale_x_continuous(breaks = seq(1, 6, 0.33))

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

As always, you are succinct without wasting time. I really appreciate the detail without repetition. If one video of yours doesn't explain exactly what I am looking for, I know another one will.

valerierussell
Автор

Very concise and informative. Thank you!

jeevanjose
Автор

Joachim,
A very nice and clean presentation. I know that the word used for the tick marks is called "breaks". I find that a bit misleading because in my mind that means that the axis has been "broken". In order words we have a graph that goes from say 0 to 10, breaks and then continues from 30 to 40 on either axis. Can you figure out how to do that? I have no idea how that might be accomplished but with the power of ggplot2 it would not surprise me if it is possible. Thanks.

haraldurkarlsson
Автор

How to change a y axies that has frequency of categorical variable in thousands; say i want to divided the label frequency by 1000

ahmedJaber
join shbcf.ru