Git Product home page Git Product logo

Comments (12)

 avatar commented on June 8, 2024 1

It's not a problem; these discussions are important 👍

from colourvalues.

tim-salabim avatar tim-salabim commented on June 8, 2024

What about a na.alpha to e.g. set all NAs as transparent?

from colourvalues.

 avatar commented on June 8, 2024

<sorry - misread your request>

yes - good idea.

from colourvalues.

 avatar commented on June 8, 2024

@tim-salabim can I get your thoughts on this scenario:

Given this function call

colour_values(1:5, alpha = 1:5)

should the alpha values be

  1. left as-is 1:5 (which, when converted to RRGGBBAA will be in the region of "00"), or
  2. assumed to be a variable which needs to be scaled to 1:5 / 5 * 255 (so when converted will be "00","3F","7F","BF","FF" ?

from colourvalues.

tim-salabim avatar tim-salabim commented on June 8, 2024

I'd say 2. If you're scaling the values you should also scale the alpha vector.
But I'd also say alpha should be within [0,1].

Also, would someone actually want to specify a vector of alpha? The most common scenarios in my opinion are:

  1. a constant alpha over all values
  2. a special alpha for special values (i.e. NAs)
  3. mapping of alpha to a (second) variable (in which case the UI usually accepts the name of a df column).

For 3. it should then be scaled to the same as the values vector.

from colourvalues.

 avatar commented on June 8, 2024

I'm inclined to agree, and I think this point is key

mapping of alpha to a (second) variable (in which case the UI usually accepts the name of a df column).

With regards to

But I'd also say alpha should be within [0,1].

If we're scaling a column/vector of data then I don't think it matters the range of the values, as they have to be in [0,255] to be converted to #RRGGBBAA

from colourvalues.

tim-salabim avatar tim-salabim commented on June 8, 2024

If we're scaling a column/vector of data then I don't think it matters the range of the values, as they have to be in [0,255] to be converted to #RRGGBBAA

Agreed!

from colourvalues.

 avatar commented on June 8, 2024

na.alpha as 0 or 255 by default?

from colourvalues.

 avatar commented on June 8, 2024

although, it can be specified through na_colour

colour_values(c(1,2,NA,4,5), na_colour = "#80808000")
colour_values(c(1,2,NA,4,5), na_colour = "#808080FF")
colour_values(c(1,2,NA,4,5), na_colour = "#80808080")

from colourvalues.

tim-salabim avatar tim-salabim commented on June 8, 2024

I'd use the same default as alpha

from colourvalues.

 avatar commented on June 8, 2024

Do you think a separate na.alpha is needed given it can be specified in na_colour ?

from colourvalues.

tim-salabim avatar tim-salabim commented on June 8, 2024

It depends, for leaflet e.g. the 8-digit hex notation was not respected (i.e. nothing was shown if in 8-digit hex) in some cases with the earlier (pre leafletjs 1.x). I am not sure how well 8-digit hex is supported in general (i.e. beyond web).

My approach in such cases is usually to not overload the api but wait and see if there is a need, so I would not implement it for now and highlight how to set it via na_colour.

Sorry for causing the stir and then recommend to not implement it... I had forgotten why we implemented a specific na.alpha in mapview.

from colourvalues.

Related Issues (20)

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.