Comments (4)
For horizontal plots with multiple layers, it will work better if you make it vertically and then use coord_flip
from ggblanket.
Option A: magic + coord_flip if adding layers
Option B: No magic + everything works
from ggblanket.
This relates to 411 in scales
from ggblanket.
- If users are building a horizontal plot that includes multiple geoms, it is recommended that users build the plot vertically with ggblanket - and then use
ggplot2::coord_flip
to make it horizontally.
Users need to ensure that the scales built by their gg_*
function are appropriate for subsequent layers. Plot scales are built by the gg_*
function based on the data
, x
, y
, *_limits
, *_include
, stat
, position
and coord
arguments in the gg_*
function.
# ggblanket + ggplot2
d <- penguins2 |>
group_by(species) |>
summarise(body_mass_g = mean(body_mass_g)) |>
mutate(lower = body_mass_g * 0.95) |>
mutate(upper = body_mass_g * 1.2)
p1 <- d |>
gg_col(
x = species,
y = body_mass_g,
col = species,
width = 0.75,
y_include = c(0, max(d$upper)),
y_labels = \(x) x / 1000,
y_title = "Body mass kg",
x_gridlines = TRUE,
y_gridlines = FALSE,
col_legend_place = "n") +
geom_errorbar(aes(ymin = lower, ymax = upper),
colour = "black",
width = 0.1) +
coord_flip()
p2 <- d |>
gg_col(
x = species,
y = body_mass_g,
col = species,
colour = "#d3d3d3",
fill = "#d3d3d3",
width = 0.75,
y_include = c(0, max(d$upper)),
y_labels = \(x) x / 1000,
y_title = "Body mass kg",
x_gridlines = TRUE,
y_gridlines = FALSE,
col_legend_place = "n") +
geom_errorbar(aes(ymin = lower, ymax = upper),
width = 0.1) +
coord_flip()
p1 / p2
from ggblanket.
Related Issues (20)
- pal: add jumble, require viridisLite, internalise & remove pal_* functions HOT 4
- pal: change pal_blue to steelblue HOT 1
- pal: replace pal_grey with #bebebe (i.e. grey) HOT 1
- viridis!
- pal in dark_mode: is contrast okay? HOT 1
- rlang::is_null not acting in expected ways
- extensions: patchwork code gone missing HOT 1
- guardian tweaking HOT 6
- pal: steelblue or guardian(1) HOT 1
- Where legend is top, there is too much space HOT 1
- Pal: try replace steel blue with mako HOT 1
- extensions: correct ggtext example HOT 1
- internals: remove `draw.ulim = TRUE` & `draw.llim = TRUE`
- col_scale: should be more flexible than TRUE/FALSE HOT 1
- col_legend_place: change examples to write them out in full
- ggdensity: HOT 1
- extensions: ggnewscale does not work as expected HOT 1
- col: logical variables are not working HOT 1
- col_legend_place: remove shortcut HOT 1
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 ggblanket.