Git Product home page Git Product logo

metbrewer's Issues

Seurat

Hi!
Love the color palettes!
a quick idea that I think those of us analyzing single cell sequencing data would get a kick out of-
The most popular package for these analyses is called Seurat since we make a lot of UMAP plots, and it looks like Study for "A Sunday on La Grande Jatte" has been in and out of the Met's collection a few times ๐Ÿ‘€

`...` arg missing from ggplot2 calls

Howdy! The package documentation notes that the arg ... can be used to pass arguments to underlying ggplot2 functions (scale_*_gradientn() and discrete_scale()), but looking at the function internals, this is actually missing (found this out when trying to get the limits arg for scale_color_gradientn() to work). It should be a pretty easy add --- let me know if you'd like me to open a PR

Istallation issue

Hello, when I run the installation code in RStudio:

devtools::install_github("BlakeRMills/MetBrewer")

I get the following error message:
Error: Failed to install 'unknown package' from GitHub:
HTTP error 404.
No commit found for the ref master

Did you spell the repo owner (BlakeRMills) and repo name (MetBrewer) correctly?

  • If spelling is correct, check that you have the required permissions to access the repo.

... not being passed to scale_fill_met_c

scale_fill_met_c does not currently pass the ... argument which means none of the additional options (e.g. limits, oob) get passed to scale_fill_gradientn

# no limits
ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width, fill = Petal.Length)) + 
  geom_tile() +
  scale_fill_met_c(name = "Homer1", limits = c(0,4), oob = scales::squish)
# correct passing of ...
scale_fill_met_c <- function(name, direction=1, ...){
  `%notin%` <- Negate(`%in%`)
  if (direction %notin% c(1, -1)){
    stop("Direction not valid. Please use 1 for standard palette or -1 for reversed palette.")
  }
  scale_fill_gradientn(colors=met.brewer(name=name, direction=direction, override.order = F), ...) # passed
}

# fixed
ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width, fill = Petal.Length)) + 
  geom_tile() +
  scale_fill_met_c(name = "Homer1", limits = c(0,4), oob = scales::squish)
> sessionInfo()
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.utf8  LC_CTYPE=English_Australia.utf8    LC_MONETARY=English_Australia.utf8 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_3.3.6   MetBrewer_0.2.0

loaded via a namespace (and not attached):
 [1] magrittr_2.0.3   tidyselect_1.1.2 munsell_0.5.0    colorspace_2.0-3 R6_2.5.1         rlang_1.0.2      fansi_1.0.3      dplyr_1.0.9     
 [9] tools_4.2.0      grid_4.2.0       gtable_0.3.0     utf8_1.2.2       cli_3.3.0        DBI_1.1.2        withr_2.5.0      ellipsis_0.3.2  
[17] assertthat_0.2.1 tibble_3.1.7     lifecycle_1.0.1  crayon_1.5.1     purrr_0.3.4      vctrs_0.4.1      glue_1.6.2       compiler_4.2.0  
[25] pillar_1.7.0     generics_0.1.2   scales_1.2.0     pkgconfig_2.0.3

Labels not working for scale_*_met_d()

Hi Blake,

I love this newest version of MetBrewer so much! I've been introducing colleagues to it very enthusiastically. Unfortunately I just spotted that I can't set custom legend labels in scale_*_met_d() using labels in the usual way. Here's an example.

data(iris)

iris_labs <- paste("I.", levels(iris$Species))
names(iris_labs) <- levels(iris$Species)

# Species labels changed successfully
ggplot(iris, aes(x = Petal.Length, y = Petal.Width, colour = Species)) +
  geom_point() +
  scale_colour_discrete(labels = iris_labs)

# Species labels not changed
ggplot(iris, aes(x = Petal.Length, y = Petal.Width, colour = Species)) +
  geom_point() +
  scale_colour_met_d("Renoir", labels = iris_labs)

Not a huge issue, but worth keeping in mind for future versions!

Cheers,
Lyuba

Duplicated argument name "name"

Hi Blake, thanks for these great palettes and for including {ggplot2} scales! I just noticed that you are using name as the argument for the palette name. Unfortunately, this is overriding the usual name argument to control the title of the legend. May you consider changing it to something else, e.g. palette or option?

Python example not working

The Python example in the README.md does not work when importing as import met_brewer. It returns: NameError: name 'met_brew' is not defined.
The easiest way to temporarily solve it is by directly calling the function, from met_bewer import met_brew. This behavior occurs on various laptops and OS.

Conda package

Thanks for the neat package!

I just wanted to let you know the package has been added to Conda Forge (r-metbrewer-feedstock), so those who manage R environments with Conda can install it with:

conda install -c conda-forge r-metbrewer

The Conda Forge repository automatically tracks CRAN, so there isn't anything here that needs to change. There are some Conda Forge badges available (see README), in case you want to add them to the README here. E.g.,

Conda Version Conda Downloads

Feel free to close this Issue after reading - just want to share the info.

Feature Request: Export formats of color codes

Provide a helper function for exporting the colors to different formats, e.g. decimal, relative 0 to 1, xml strings etc.

Currently, the color codes are native to hexadecimal strings.

The API could support a dictionary as data type which can be directly converted to a JSON file for instance for later use.

Decimal DEC

{'colors': [(221, 81, 41), (15, 122, 162), (66, 178, 131), (250, 178, 85)],
 'name': 'Egypt'}

Relative [0, 1] REL

{'colors': [(0.8666666666666667, 0.3176470588235297, 0.1607843137254903),
            (0.05882352941176472, 0.48235294117647026, 0.6352941176470588),
            (0.26274509803921564, 0.6980392156862745, 0.5176470588235293),
            (0.9803921568627451, 0.6980392156862747, 0.33333333333333337)],
 'name': 'Egypt'}

XML

{'colors': [(0.8666666666666667, 0.3176470588235297, 0.1607843137254903),
            (0.05882352941176472, 0.48235294117647026, 0.6352941176470588),
            (0.26274509803921564, 0.6980392156862745, 0.5176470588235293),
            (0.9803921568627451, 0.6980392156862747, 0.33333333333333337)],
 'name': 'Egypt',
 'tags': ['<color name="Egypt-1" value="0.8666666666666667 0.3176470588235297 '
          '0.1607843137254903" />',
          '<color name="Egypt-2" value="0.05882352941176472 '
          '0.48235294117647026 0.6352941176470588" />',
          '<color name="Egypt-3" value="0.26274509803921564 0.6980392156862745 '
          '0.5176470588235293" />',
          '<color name="Egypt-4" value="0.9803921568627451 0.6980392156862747 '
          '0.33333333333333337" />']}
<color name="Egypt-1" value="0.8666666666666667 0.3176470588235297 0.1607843137254903" />
<color name="Egypt-2" value="0.05882352941176472 0.48235294117647026 0.6352941176470588" />
<color name="Egypt-3" value="0.26274509803921564 0.6980392156862745 0.5176470588235293" />
<color name="Egypt-4" value="0.9803921568627451 0.6980392156862747 0.33333333333333337" />

Add a transparency argument for R

Hello, many thanks for MetBrewer! Would it be possible to add an argument for transparency? Ideally it would be a vector that control the transparency of each colour of the palette (with the possibility of recycling the vector on R).

I think you are using colorRampPalette in you generator. There is now an argument alpha for the transparency. See this answer on stackoverflow

How to set pallet in ggplot2

Hello, thanks for MetBrewer!

Could you show how i can apply palettes from it to ggplot2 plots?

For example, next code it works,

library(ggplot2)
library(MetBrewer)

ggplot(data=iris, 
       aes(x=Sepal.Length, 
           y=Petal.Length, 
           color=Species))+
  ggtitle("Iris")+
  geom_point()+
  scale_color_manual(values = MetBrewer::MetPalettes$Cross[[1]][1:3])

but i think there should be a more graceful way to apply the palette.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.