I would like to align two plots in R, generated with the image()
function.
Sample code:
# Load package
library(cowplot)
# Plot sample image
image <- image(matrix(rnorm(1000), 100,100))
# Align plots
plot_grid(image, image)
However, when I do it like this, the plots do not appear. Am I missing something? Or can cowplot not handle plots generated from the image function?
If you want to use cowplot for base-R plots, I highly recommend using the current development version of cowplot. In that version, you can simply turn your image code into a formula (by adding ~
in front) and it will work.
library(cowplot)
#>
#>
#> *******************************************************
#> Note: cowplot does not change the default ggplot2 theme
#> anymore. To recover the previous behavior, execute:
#> theme_set(theme_cowplot())
#> *******************************************************
# Plot sample image
image <- ~image(matrix(rnorm(1000), 100,100))
# Align plots
plot_grid(image, image)
Created on 2018-10-27 by the reprex package (v0.2.1)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.