Git Product home page Git Product logo

Comments (9)

teunbrand avatar teunbrand commented on September 4, 2024 1

Thanks for the report David, you can see why I've labelled the package as experimental 😅
Should be a straightforward fix.

from gguidance.

teunbrand avatar teunbrand commented on September 4, 2024 1

then there is a tick only every 2nd break

Yes but this is also what happens when you use e.g. theme(axis.ticks.length.x.bottom = rel(c(0, 1))), so I'd say this is the typical outcome of specifying tick lengths.

In addition to above, are you planning on adding second_guide functionality to guide_colourbar_custom and guide_colour_ring?

No they already have first_guide and second_guide arguments. It is dependent on the legend.text.position where the first and where the second is drawn. The colour ring has inner_guide and outer_guide arguments that have the same role, but are not dependent on the theme (as legend.text.position = "outside" is not a valid option).

from gguidance.

teunbrand avatar teunbrand commented on September 4, 2024 1

it works differently to ggplot2::guide_colourbar which keeps all ticks in that situation.

True, but I'm not going to mirror that guide perfectly as I'd like to be free of the historic bagage of that guide so that I can do it the way I think it is best. Primarily, it is important to me that the tickmarks and labels are individual guides that can be tweaked as one sees fit separately from the colourbar itself. In the process, we might lose nuances like that, but it is still very much possible to achieve the same result.

from gguidance.

davidhodge931 avatar davidhodge931 commented on September 4, 2024

Thanks for the fixes!

It's all weirder edge-case stuff anyway, but might as well fix if it's not too hard

from gguidance.

teunbrand avatar teunbrand commented on September 4, 2024

Should no longer throw any errors:

library(gguidance)
#> Loading required package: ggplot2
library(tidyverse)
library(palmerpenguins)

penguins |>
  ggplot() +
  geom_point(
    aes(x = flipper_length_mm,
        y = species,
        colour = flipper_length_mm)) +
  guides(
    colour = guide_colourbar_custom(),
  ) +
  theme(legend.ticks.length = ggplot2::rel(c(0.15, 0)))
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_point()`).

Note that implementation differs from ggplot2, because of the 'little guides in a trenchcoat' approach.
To mirror ggplot2's approach to disabling ticks on one side, you can do the following:

penguins |>
  ggplot() +
  geom_point(
    aes(x = flipper_length_mm,
        y = species,
        colour = flipper_length_mm)) +
  guides(
    colour = guide_colourbar_custom(second_guide = "none"),
  )
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_point()`).

Created on 2024-04-27 with reprex v2.1.0

from gguidance.

davidhodge931 avatar davidhodge931 commented on September 4, 2024

Awesome, thanks!

Minor thing - if your theme that you've added already has 2 elements in it, then there is a tick only every 2nd break even once you add second_guide = "none"

library(gguidance)
library(tidyverse)
library(palmerpenguins)

penguins |>
  ggplot() +
  geom_point(
    aes(x = flipper_length_mm,
    y = species,
    col = flipper_length_mm),
  ) +
  scale_colour_gradientn(colours = blues9, limits = c(NA, 220)) +
  theme(legend.ticks.length = rel(c(0, 0.5))) +
  guides(colour = guide_colourbar_custom(second_guide = "none"))

image

from gguidance.

davidhodge931 avatar davidhodge931 commented on September 4, 2024

In addition to above, are you planning on adding second_guide functionality to guide_colourbar_custom and guide_colour_ring?

from gguidance.

davidhodge931 avatar davidhodge931 commented on September 4, 2024

Re the 2nd break thing, it works differently to ggplot2::guide_colourbar which keeps all ticks in that situation.

Re the first_guide/second guide, whoops missed that

from gguidance.

davidhodge931 avatar davidhodge931 commented on September 4, 2024

Fair enough - sounds like a good approach

from gguidance.

Related Issues (13)

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.