Giter VIP home page Giter VIP logo

Comments (2)

matt-dray avatar matt-dray commented on June 1, 2024

Hi Petr, it's taken me a while to get round to this. This should now work:

remotes::install_github("matt-dray/coloratio")
coloratio::cr_choose_bw(c("white", "black"))
## [1] "black" "white"

Does that help?

I haven't closed this issue because I haven't yet vectorisedcr_choose_color(). This function is a bit different to cr_choose_bw() because the user can set the length of the return object with n (i.e. they want the n colors with greatest contrast). So, vectorising cr_choose_color() might mean returning a list of the same length as col, with elements that are all of length n. Or maybe n is coerced to 1 when a vector of length 2 more more is supplied to col, i.e. it will only return the single color with greatest contrast. Ideas welcome!

from coloratio.

petrbouchal avatar petrbouchal commented on June 1, 2024

Hi Matt,

I just stumbled upon a similar situation (labelling a heatmap) in my work and was reminded of this exchange - sorry for not reacting! Many thanks, it does help indeed.

Re cr_choose_color(), returning a list would not make it usable in after_scale(), so with that purpose in mind I would go for the latter option, but then perhaps there are other use cases.

Alternatively, you could have cr_choose_one_color() or allow the user to control the type of output via an argument, but that makes things a bit opaque.

from coloratio.

Related Issues (14)

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.