Comments (9)
Thanks for the report David, you can see why I've labelled the package as experimental 😅
Should be a straightforward fix.
from gguidance.
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.
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.
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.
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.
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"))
from gguidance.
In addition to above, are you planning on adding second_guide
functionality to guide_colourbar_custom
and guide_colour_ring
?
from gguidance.
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.
Fair enough - sounds like a good approach
from gguidance.
Related Issues (13)
- Separate element for minor ticks HOT 1
- Better names for functions ending in `_custom()` HOT 6
- `guide_coloursteps_custom` does not respect `theme(legend.ticks = ...))` HOT 2
- tangent circle legend for size legend
- nested axis guide from ggh4x
- A cap of legend in fill scale HOT 4
- Suggestion: Excel-style grouped axes
- Cannot install it HOT 4
- Idea: interpolate glyphs with text HOT 1
- Idea: custom grobs parallel to key HOT 1
- legends for colour & fill not merging with guide_custom HOT 2
- guide_colourbar_custom throws error with theme(legend.key.spacing = NULL) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gguidance.