Giter VIP home page Giter VIP logo

Comments (8)

hadley avatar hadley commented on September 1, 2024

Have you had any more thoughts on this?

from scales.

sjackman avatar sjackman commented on September 1, 2024

Somewhat related, I really like the "engineering" 1-2-5 log scale:
1 2 5 10 20 50 100 200 500 et cetera
See https://en.wikipedia.org/wiki/Preferred_number#1-2-5_series

from scales.

hadley avatar hadley commented on September 1, 2024

@sjackman want to contribute a labeller???

from scales.

sjackman avatar sjackman commented on September 1, 2024

Yeah, actually, I would. The next time it comes up, I'll do that. Can you point me to a template of code that I can crib and modify?

from scales.

hadley avatar hadley commented on September 1, 2024

@sjackman I'd start with the existing log_breaks(): https://github.com/hadley/scales/blob/master/R/breaks.r#L47

from scales.

cb4github avatar cb4github commented on September 1, 2024

Might this be what you had in mind:

log_breaks_fill <- function(fill = "full", ...) {
  function(x) {
    sparse <- log_breaks(...)(x)
    if (fill == "eng") {
      fillVec <- c(1,2,5)
    } else if (fill == "full") {
      fillVec <- 1:9
    } else if (fill == "none") {
      fillVec <- 1
    } else {
      warning(paste0("Unrecognized fill option ignored:", fill))
      fillVec <- 1
    }
    return(as.vector(fillVec %o% sparse))
  }
}

from scales.

sjackman avatar sjackman commented on September 1, 2024

I'll try that out. Thanks!

from scales.

sjackman avatar sjackman commented on September 1, 2024

@cb4github The following works very well. Thanks for the suggestion!

library(scales)
library(tidyverse)
log_breaks_125 <- function(...) c(1, 2, 5) %o% log_breaks()(...)
ggplot(diamonds, aes(x = carat, y = price)) +
	scale_x_log10(breaks = log_breaks_125) +
	scale_y_log10(breaks = log_breaks_125) +
	geom_point()

image

from scales.

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.