Giter Club home page Giter Club logo

Comments (8)

yihui avatar yihui commented on June 14, 2024

colorBin() is based on pretty(), and the price of making bins "pretty" is that it is you are unlikely to get exactly n bins. If you want to get exactly n bins, the cut points will not be "pretty" (e.g. numbers with 16 digits after the decimal point).

from leaflet.

smartinsightsfromdata avatar smartinsightsfromdata commented on June 14, 2024

@yihui great to know, but...

I think we should clearly spilt the problem in two:

  • how many bins do I want to use? I must be able to specify the number of bins I want to use, either using colorBin (or colorFactor). If colorBin (or pretty()) decides for me how many bins is using, it is not (much) useful.
  • what is the format of the data in the legend? On the legend data format issue I've already posted a feature request here. This discussion reinforces the need to address legend data formatting (maybe using the scale package?).

Suppose that I've used a not-pretty number of bins (e.g. with lots of decimals). I wouldn't see a problem if the legend data is just approximate: I would use a popup to display the actual value in each area to clarify any ambiguity. What would it matter to know precisely where the cut occurred? In most cases it wouldn't.

For me, a legend of a choropleth map needs to give an idea at a glance of the order of magnitude of the areas, especially if there is an easy way to get the actual detail (e.g. popup).

In any case, may I suggest to mention in the help that the number of bins are forced by pretty()?

At the moment it says only:

colorBin also maps continuous numeric data, but performs binning based on value (see the cut function).

Thanks

from leaflet.

smartinsightsfromdata avatar smartinsightsfromdata commented on June 14, 2024

@yihui As a way to extend the ability to define different binning approaches, I suggest to integrate the package β€˜classInt’ by Roger Bivand.

from leaflet.

yihui avatar yihui commented on June 14, 2024

Thanks! I have addressed the documentation in #53, in which you will also be able to format the labels by yourself if you provide the bins vector of non-pretty numbers. Supporting classInt is trivial in the sense that you simply call classInt::classIntervals(var, n) and pass $brks to bins in colorBin(). I'd rather not introduce the dependency on another package.

from leaflet.

smartinsightsfromdata avatar smartinsightsfromdata commented on June 14, 2024

πŸ‘ thanks (but I would prefer pretty as an option...)

from leaflet.

yihui avatar yihui commented on June 14, 2024

@smartinsightsfromdata Just added an argument pretty = TRUE to colorBin(), so you can choose to use exactly n bins generated from seq(min, max, length = n).

from leaflet.

smartinsightsfromdata avatar smartinsightsfromdata commented on June 14, 2024

πŸ‘ πŸ‘

from leaflet.

yihui avatar yihui commented on June 14, 2024

I forgot to mention it was still in the PR #53 and has not been merged to the master branch yet.

from leaflet.

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.