Reputation: 1
I'm try to create a time series where, x = year
, y = cpue_wt
, grouped by station. I have 7 stations: Here is a snapshot of the data, which goes from 1986-2011. I want one plot, with 7 different lines, each represents one station through time.
year station cpue_wt
1986 531 3.400346954
1986 537 1.292539282
1986 538 1.097930493
1986 541 1.220753481
1986 550 1.350880331
1986 552 1.168257879
1986 555 2.012733899
1987 531 1.817902609
1987 537 2.024999967
1987 538 1.563596954
Here is the code I'm trying to use:
SST <- ggplot(Yrsta, aes(group = factor(station), x = year, y = cpue_wt, colour = station)) + geom_line() + scale_color_manual(values=c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00"))
Here is my error:
Continuous value supplied to discrete scale
I'm assuming my data are not organized correctly.
Any help would be greatly appreciated.
Upvotes: 0
Views: 1133
Reputation: 98419
As station
values are numeric and you want to set particular color for each line, you should add as.factor(station)
to colour=
to convert numerical values to factor.
ggplot(Yrsta, aes(group = factor(station), x = year, y = cpue_wt, colour = as.factor(station))) +
geom_line() +
scale_color_manual(values=c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00"))
Upvotes: 1