hadley / ggplot2-book

ggplot2: elegant graphics for data analysis
https://ggplot2-book.org/
1.55k stars 676 forks source link

Rendering book fails at scales-other.qmd #399

Open py9mrg opened 1 month ago

py9mrg commented 1 month ago

Hello,

When rendering the book (quarto render --to pdf) there is a failure in scales-other.qmd as per:

Error in `discrete_scale()`:
! formal argument "palette" matched by multiple actual arguments
Backtrace:
 1. ggplot2::scale_linetype(palette = linetypes)

Quitting from lines 259-266 [unnamed-chunk-18] (scales-other.qmd)
Execution halted

The offending lines are:

linetypes <- function(n) {
  types <- c("55",  "75", "95", "1115", "111115", "11111115",
             "5158", "9198", "c1c8")
  return(types[seq_len(n)])
}

base + scale_linetype(palette = linetypes)

I guess this is due to some of the changes in discrete_scale()?

Thanks.

py9mrg commented 1 month ago

Adding reference to https://github.com/tidyverse/ggplot2/issues/5991

teunbrand commented 1 month ago

TL;DR from https://github.com/tidyverse/ggplot2/issues/5991#issuecomment-2220305051: The book is wrong, scale_linetype() does not accept a palette argument, and only worked before by accident.

I'd recommend that the book uses scale_linetype_manual() to demonstrate the hexadecimal linetypes.