当前位置:网站首页>ggplot2显示png
ggplot2显示png
2022-07-24 02:08:00 【qq_45759229】
一般情况下来说,ggplot2画的图是我们ggplot自己建立起来的对象,但是有的时候,为了排版的美观,我需要从外地导入一张图片从而和其他ggplot对象一起进行操作,操作如下
案例1
library(ggplot2)
library(cowplot)
library(magick)
library(patchwork)
# Update 2020-04-15:
# As of version 1.0.0, cowplot does not change the default ggplot2 theme anymore.
# So, either we add theme_cowplot() when we build the graph
# (commented out in the example below),
# or we set theme_set(theme_cowplot()) at the beginning of our script:
theme_set(theme_cowplot())
my_plot <-
ggplot(data = iris,
mapping = aes(x = Sepal.Length,
fill = Species)) +
geom_density(alpha = 0.7) # +
# theme_cowplot()
# Example with PNG (for fun, the OP's avatar - I love the raccoon)
p1=ggdraw() +
draw_image("./dog.jpeg")
p2=ggdraw() +
draw_image("./dog.jpeg")
p1+p2
结果如下
案例2
library(ggplot2)
library(cowplot)
library(magick)
library(patchwork)
# Update 2020-04-15:
# As of version 1.0.0, cowplot does not change the default ggplot2 theme anymore.
# So, either we add theme_cowplot() when we build the graph
# (commented out in the example below),
# or we set theme_set(theme_cowplot()) at the beginning of our script:
theme_set(theme_cowplot())
my_plot <-
ggplot(data = iris,
mapping = aes(x = Sepal.Length,
fill = Species)) +
geom_density(alpha = 0.7) # +
# theme_cowplot()
# Example with PNG (for fun, the OP's avatar - I love the raccoon)
p1=ggdraw() +
draw_image("./dog.jpeg")
p2=ggdraw() +
draw_image("./test_sanky.png")
p1+p2

案例3
library(ggplot2)
library(cowplot)
library(magick)
library(patchwork)
# Update 2020-04-15:
# As of version 1.0.0, cowplot does not change the default ggplot2 theme anymore.
# So, either we add theme_cowplot() when we build the graph
# (commented out in the example below),
# or we set theme_set(theme_cowplot()) at the beginning of our script:
theme_set(theme_cowplot())
my_plot <-
ggplot(data = iris,
mapping = aes(x = Sepal.Length,
fill = Species)) +
geom_density(alpha = 0.7) # +
# theme_cowplot()
# Example with PNG (for fun, the OP's avatar - I love the raccoon)
p1=ggdraw() +
draw_image("./dog.jpeg")
p2=ggdraw() +
draw_image("./test_sanky.png",scale = 2)
p1+p2
结果如下
这里顺便记录一下在linux ubuntu上安装
首先
sudo apt-get install -y libmagick++-dev
然后进入conda的R环境,
install.packages("magick")
但是这里出错了
解决办法
然后再次
install.packages("magick")
然后就成功了
边栏推荐
- 医院无线网络系统设计
- Quick sort considerations
- Wenxin big model raises a new "sail", and the tide of industrial application has arrived
- LoadRunner12安装、录制第一个脚本以及代理服务器没有响应解决
- Cmake Getting Started tutorial
- 暑假第三周
- 20220723 record an unexplained shutdown of SAP Oracle monitoring service
- 以科技传递温度,vivo守护生物多样性之美
- 医院网络安全架构
- Computer room construction data
猜你喜欢

xxl-job使用注意事项
![[C language operation of linked list (initialization, establishment, length calculation, addition, deletion, and output of linked list)]](/img/9b/e5cda39c04d0cc2f69e43c97ee997d.png)
[C language operation of linked list (initialization, establishment, length calculation, addition, deletion, and output of linked list)]

Cartland number---

View binding confusion. I have been studying confusion for two days.

Distributed resource management and task scheduling framework yarn

How to install, download and use the latest version of IDM software

Yinshimei Invisalign oral scan referral method (export oral scan data + online consultation)

php7 垃圾回收机制详解

LiteSpeed Web服务器中安装SSL证书

Graduation design campus information publishing platform website source code
随机推荐
响应式布局一个网页在不同设备显示不同效果)meta:vp
Exchange 2010通配符SSL证书安装文档
After five years of contact with nearly 100 bosses, as a headhunter, I found that the secret of promotion was only four words
jenkins多任务并发构建
Install SSL Certificate in Litespeed web server
What are the principal guaranteed financial products with an annual interest rate of about 6%?
jmeter+influxdb+grafana压测实时监控平台搭建
hdu-7141 Ball (bitset)
Local empowerment learning
Qt::WA_ Transparentformouseevents
Is Huatai Securities safe to open an account? How to handle it
Construction and test of hfish honey pot
LoadRunner12安装、录制第一个脚本以及代理服务器没有响应解决
How QT counts the frequency of letters in a string
医院网络安全架构
Magazine feature: the metauniverse will reshape our lives, and we need to make sure it gets better
暑假第三周
[重要通知]星球线上培训第三期来袭!讲解如何在QTYX上构建自己的量化策略!...
快速排序注意点
架构实战营模块二作业