0

I have a geom_point graph that plots a bad x-axis, I am trying to add manual breaks, which works perfectly until I try a break under the value of 100. Anything above that works fine, but it just won't add them below 100, I get no error message.

A simplified version of the graph:

ggplot(mapping = aes(x = Julian_Date, y = cum_Pigfish)) +
geom_point(seagrass_cover_cleaned_fixed_column_names_no_NA_2009, 
           mapping = aes(x = Julian_Date, y = cum_Pigfish, color = "Blue")) +
scale_x_discrete(breaks = seq(0,366, 30))

An image of the resulting graph:

The graph

neilfws
  • 32,751
  • 5
  • 50
  • 63
  • 1
    Welcome to Stack Overflow. Please [make this question reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) by including a small representative dataset in a plain text format. Please also check your code: it was missing a "+" symbol, and I do not see the name of a data frame required by `ggplot`. – neilfws Sep 13 '22 at 23:48
  • 1
    In addition: I think your issue may be that the Julian Date variable is of type character or factor, rather than numeric. – neilfws Sep 14 '22 at 00:15
  • coerce the "Julian Date" to numeric variable and try scale_x_continuous(limits = c(0, 366), breaks = c(0, 366, 30)) instead. – AlpacaKing Sep 14 '22 at 04:07
  • The full code for the graph: ggplot(mapping = aes(x = as.numeric(Julian_Date), y = as.numeric(cum_Pigfish))) + geom_point(seagrass_cover_cleaned_fixed_column_names_no_NA_2009, mapping = aes(x = Julian_Date, y = cum_Pigfish, color = "2009")) + labs(x = "Julian Date", y = "Cumulative Pigfish Catch", title = "Yearly Cumulative Pigfish Counts", color = "Legend") + scale_color_manual(values = colors) + scale_x_discrete(breaks = seq(0,366, 50)). Even when I coerce variables to be numeric it says I can't use scale_x_continuous, and when I tried using alpacaking's breaks it's still wrong. – Ari Siegel Sep 14 '22 at 15:09
  • @AriSiegel: Welcome to Stack Overflow! Like neilfws already asked, please check out the answers to [How to make a great R reproducible example?](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Caspar V. Sep 14 '22 at 22:37

0 Answers0