DS4PS / cpp-526-fall-2019

Course material for CPP 526 Foundations of Data Science I
http://ds4ps.org/cpp-526-fall-2019
4 stars 4 forks source link

Lab 03 issues #16

Open etbartell opened 5 years ago

etbartell commented 5 years ago

I had a couple of questions about lab 3:

1) Is there a way under the plot.new function to change where tick marks are drawn on the x-axis? I've tried a few things including:

axis(side=1, labels(c(1900,1910,1920,....,2010) -- This results in no tick marks
axis(side=1, at=10) -- This results in no tick marks
axis(side=1, labels(years, at=10))  -- This results in tick marks drawn at intervals of 1 ('at' seems to be ignored)

2) Is there a way to include the subtitle or axis titles anywhere except their default positions (for example, the sub-title is defaulted to the bottom)?

3) Do we need to include the interactive legend with the option to show individual teams?

Thanks!

sunaynagoel commented 5 years ago

@etbartell I have same questions as your number 2 and 3

I also wanted to change colors Main title and Axis title I tried various combinations, nothing seems to be working.

lecy commented 5 years ago

The best thing to do with these functions is type args(axis) or help(axis) to get some of the options.

> args( axis )
function (side, at = NULL, labels = TRUE, tick = TRUE, line = NA, 
    pos = NA, outer = FALSE, font = NA, lty = "solid", lwd = 1, 
    lwd.ticks = lwd, col = NULL, col.ticks = NULL, hadj = NA, 
    padj = NA, ...) 

I believe you need something like:

axis( side=1, at=c(1920,1950,1980), labels=c(1920,1950,1980) )

For colors, col= controls tick marks, and col.axis= controls labels.

axis( side=1, col="blue", col.axis="red" )
lecy commented 5 years ago

@etbartell nothing interactive on this lab. That is next week!

mlgaona1717 commented 5 years ago

Hi everyone! I am trying to add two different sized text into my plot. I have this:

text( x=1924, y=2.7, label="League Average \n1924", cex=1.5, col=1 )
text( x=2012, y=7.5, label="League Average \n2012", cex=1.5, col=1 )

... but I am trying to add the bigger text for the year, like on the sample graph. How do I add that into the code to be in the same spot as that League Average text, but be a different color and size? Thanks!

lecy commented 5 years ago

That's a little tricky. If you have a vector of strings, you can apply different sizes (cex=) to each. But with one string you can only specify one size.

The easy fix is to plot two lines of text.

text( x=1924, y=3.5, label="League Average", cex=1.5, col=1, pos=3 )
text( x=1924, y=2.7, label="1924", cex=2, col=1, pos=3 )

I'm not sure what the exact values of Y you would want here. But I think you get the idea.

The pos=3 will center the text above the point might be a little easier to fine tune.

mlgaona1717 commented 5 years ago

@lecy Gotcha, thank you so much!