DS4PS / ays-r-coding-sum-2022

Introductory data science course in R, taught at the Andrew Young School GSU.
http://ds4ps.org/ays-r-coding-sum-2022/
2 stars 2 forks source link

Lab 3 - Adding Legend & x-axis label #2

Open mugekosar opened 2 years ago

mugekosar commented 2 years ago

Hello!

I have some issues regarding adding a legend. I have tried the legend function but I was wondering which functions would you suggest to add a legend for this one?

I also realized my x-axis labels are until the year 2010 and the year 2012 doesn't show in the graph, I searched about this one but I couldn't resolve this issue too.

Replication

kyarosiuk1 commented 2 years ago

thank you for posting this question! I am facing the exact same issue...I tried to increase to 2012 but it is still not showing...

lecy commented 2 years ago

You can control the exact position and annotation of axis labels, but there are limits related to text size. You will likely not be able to fit 2012 into the axis elegantly, and not sure it adds much. But you would use the at= argument in axis().

plot( cars )

image

plot( cars, xaxt="n" )
axis( side=1, at=c(20,22,24,26) )

image

mugekosar commented 2 years ago

Thank you @lecy I'm still trying to figure out to extend the x-axis