Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
481 views
in Technique[技术] by (71.8m points)

r - What type of graph is this? And can it be created using ggplot2?

I have this chart that I'm attempting to replicate. It has two continuous variables for the X & Y axes, and charts the relationship between these two variables through time with a line.

My question has two parts:

  • First, what is this type of chart called? It is unusual because the line between the points is determined by a third variable (the year) rather than their positions on the X axis.

  • Second, does anyone know whether this can be achieved with ggplot? I have so far created a chart similar to the above but without the line connecting the points. This code ggplot(data, aes(x = Weekly_Hours_Per_Person, y = GDP_Per_Hour)) + geom_point() has gotten the below output: enter image description here But how to get the line over years?

Any help on either point will be appreciated. Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use geom_path, i.e.

libraray(ggplot2)
ggplot(data, aes(x = Weekly_Hours_Per_Person, y = GDP_Per_Hour)) +
geom_point() + 
geom_path()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...