Plotting code help

Hi the following code isn't working for me and I was wondering if anyone had some advice? I was attempting to plot the NBA players to their highest scoring games. The code is below, thanks
Points <- c (100, 81, 78, 73, 73, 73, 72, 71, 71, 70, 70, 69, 68, 68, 67, 67, 67, 67, 66, 65, 65, 65, 65, 64, 64, 64)

Year <- c (1962, 2006, 1961, 1962, 1962, 1978, 1962, 1960, 1994, 1963, 2017, 1990, 1967, 1977, 1961, 1962, 1962, 1963, 1969, 1962, 1962, 1966, 2007, 1959, 1974, 1993)

id <- c ("Wilt Chamberlin", "Kobe Bryant", " Wilt Chamberlin", " Wilt Chamberlin", " Wilt Chamberlin", " David Thompson", " Wilt Chamberlin", “Elgin Baylor”, “David Robinson”, “Wilt Chamberlin”, “Devin Booker”, “Michael Jordan”, “Wilt Chamberlin”, “Pete Maravich”, “Wilt Chamberlin”, “Wilt Chamberlin”, “Wilt Chamberlin”, “Wilt Chamberlin”, “Wilt Chamberlin”, “Wilt Chamberlin”, “Wilt Chamberlin”, “Wilt Chamberlin”, “Kobe Bryant”, “Elgin Baylor”, “Rick Barry”, “Michael Jordan”)

plot (x = Points,

y = Year,

xlim = c (50, 120),

ylim = c (1950, 2020),

pch = 16,

col = yarrr:: piratepal ("NBA"))

text (x = Points,

y = Year,

labels = id,

pos = 3)

The code works for me if I replace all of the curly quotes, “, with straight quotes, ", in the definition of the id vector. I also did not use the call to yarrr:: piratepal, since I do not have that.
The names on the plot are written on top of each other and largely illegible.

Hi, thanks for the help! Is there any way I can lower the font or just lower the amount of names used?
Thanks,

You can make the text smaller with the cex parameter of the text() function.

text (x = Points,
      
      y = Year,
      
      labels = id,
      
      pos = 3, cex = 0.5)

You can print fewer lables by using shorter versions of the vectors Points, Year and id. I would say that only the highest three Points values really stand out, so make versions of the three vectors with only those values and use them in the text() function.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.