1

I am simply trying to show the breaks on the x axis of a plot (5,4,3,2,1,.5) but it will not show the .5. When I tried to code below, it resulted in not showing any x marks whatsoever and I don't know why.

labels <- c(5,4,3,2,1,.5)

ggplot(kobe_vs_kawhi, aes(desc(Time_Left), FG_Percentage, color = Player)) +
 geom_point() +
 geom_smooth() +
 scale_x_continuous(breaks = labels) +
 scale_color_manual(values = c("red4", "gold2"))
neilfws
  • 32,751
  • 5
  • 50
  • 63
Jeff Henderson
  • 643
  • 6
  • 10
  • Please provide some or all of `kobe_vs_kawhi` to [make this question reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). I think you may want `scale_x_reverse()` instead of `scale_x_continuous()`. – neilfws May 08 '19 at 04:19
  • I'm not sure how to edit to provide the data but I have a numeric variable of time with the following numbers (5,4,3,2,1,.5) and I'd like a label for each of these on the x-axis. It doesn't want to show the .5 and I don't know how to add that to the graph. – Jeff Henderson May 08 '19 at 04:26

1 Answers1

1

Difficult to answer without data but if you want all of those x-axis values displayed and in reverse try:

ggplot(kobe_vs_kawhi, aes(Time_Left, FG_Percentage, color = Player)) +
geom_point() +
geom_smooth() +
scale_x_reverse(breaks = labels) +
expand_limits(x = c(0, 5) +
scale_color_manual(values = c("red4", "gold2"))

Note that there is no need to sort Time_Left or for labels to be in reverse order using this approach.

neilfws
  • 32,751
  • 5
  • 50
  • 63