Jim
Jim

Reputation: 725

R ggplot vary line thickness or style based on conditional

Here is a link to a .csv of my data, which I call "pop_c".

I generate a line plot using the following code:

ggplot(data = pop_c, aes(x = year, y = pop_change, color = state)) + 
  geom_line(stat="identity")

However, I would like to vary either the line's thickness, style, or shading based on the 'recession' column. If the value in the 'recession' column is 1, I'd like the line to be either: a) thicker, b) shaded darker, or c) some combination of the two.

Can someone explain how to vary a line's thickness, style, and/or shading based on such a conditional?

Upvotes: 1

Views: 1296

Answers (1)

moman822
moman822

Reputation: 1954

add alpha=recession or size=recession or linetype=recession into aes()

Upvotes: 5

Related Questions