Comments (1)
I'm sorry, there is no simple way to automate aligning heterogeneous graphs, since ggplot2 adds and removes columns depending on which elements are present in the graph. However, there is a simple workaround, which is explained at the bottom of this vignette:
require(cowplot)
require(gtable) # needed for gtable_add_cols
plot.mpg1 <- ggplot(mpg, aes(x = cty, y = hwy, colour = factor(cyl))) +
geom_point(size=2.5)
plot.mpg2 <- ggplot(mpg, aes(x = cty, y = hwy, colour = factor(cyl))) +
geom_point(size=2.5)
plot.mpg2 <- switch_axis_position(plot.mpg2, "y")
# add the two additional columns that plot.mpg2 has
g1 <- ggplotGrob(plot.mpg1)
g1 <- gtable_add_cols(g1, plot.mpg2$widths[5:6], 4)
plot_grid(g1, plot.mpg2, nrow = 2, align = "v")
from cowplot.
Related Issues (20)
- feature request: geom_image that allows plotting of several images, based on geom_rect? HOT 12
- align by axis values HOT 1
- Conversion failure warnings on unicode character HOT 3
- Label positioning is inconsistent HOT 1
- Rstudio crashed on iOS saving plots into tiff format HOT 6
- [Feature request] Icicle plot with ggplots objects
- Using expressions in plot text generates warnings
- Feature request: Add "units" parameter to all functions where size can be specified.
- Odd problem with setting alpha in an annotate geom
- [Feature request] Align legend with the start and end of the axis
- Cannot convert object of class LayerInstanceLayerggprotogg into a grob?
- changing size of the second plot in plot_grid() HOT 2
- ggarange common.legend positioning overwritten
- No side effect from plot_grid when used inside a function returning an object
- get_legend doesn't match original position
- Blank plot using plot_grid with RNotebook
- Feature request: options for anchors of labels in plot_grid HOT 1
- warning message: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0. HOT 5
- Explanation of how align_plot, ggdraw, and draw_plot work together for dual-y-axis plots.
- `draw_image` only works when background themes are set to `ggplot2::element_blank()` 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 cowplot.