Skip to content

Prevent RColorBrewer::brewer.pal warning #1999

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
May 19, 2025

Conversation

s-fleck
Copy link
Contributor

@s-fleck s-fleck commented Sep 14, 2021

RColorBrewer::brewer.pal() throws an (in this case) unnecessary warning if the output plot requires less than 2 colors. This is an easy fix, and does not change the workings of the code since RColorBrewer::brewer.pal() never returns less than three levels anywas:

> RColorBrewer::brewer.pal(2, "Set2")
[1] "#66C2A5" "#FC8D62" "#8DA0CB"
Warning message:
In RColorBrewer::brewer.pal(2, "Set2") :
  minimal value for n is 3, returning requested palette with 3 different levels

`RColorBrewer::brewer.pal()` throws an (in this case) unnecessary warning if the output plot requires less than 2 colors. This is an easy fix, and does not change the workings of the code since `RColorBrewer::brewer.pal()` never returns less than three levels anywas:

```
> RColorBrewer::brewer.pal(2, "Set2")
[1] "#66C2A5" "#FC8D62" "#8DA0CB"
Warning message:
In RColorBrewer::brewer.pal(2, "Set2") :
  minimal value for n is 3, returning requested palette with 3 different levels
```
@cpsievert
Copy link
Collaborator

Thanks!

@cpsievert cpsievert merged commit 3bd4448 into plotly:master May 19, 2025
cpsievert added a commit that referenced this pull request Jun 5, 2025
* Follow up to #1999: update test expectation to not expect warning

* Temporarily test against CRAN ggplot2

* Avoid :: on old ggplot2 function

* Disable oldrel-4; roxygen stuff

* Update URL

* Try to fix kaliedo install

* Fix more roxygen issues

* Pass data to use_defaults() method (this way GeomSf default aes logic will actually work as expected)

* Approve new snapshots

* Revert "Pass data to use_defaults() method (this way GeomSf default aes logic will actually work as expected)"

This reverts commit 01e73fb.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants