当前位置:网站首页>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")
然后就成功了
边栏推荐
- In depth understanding of the underlying framework of wechat applet (II) component system, exprser
- Cinq ans de contact avec près d'une centaine de patrons, en tant que chasseur de têtes, j'a i découvert que le secret de la promotion n'est que quatre mots
- 图解数组和链表详细对比,性能测试
- Summary of volatile interview in concurrent programming
- Digicert code signing certificate
- 141. Circular linked list
- 机房建设资料
- View binding confusion. I have been studying confusion for two days.
- 奔走相告,行情与量化页面功能优化!股票量化分析工具QTYX-V2.4.5
- What are the principal guaranteed financial products with an annual interest rate of about 6%?
猜你喜欢

xxl-job使用注意事项

Notes - record a dynamic datasource please check the setting of primary problem solving

杂志特稿:元宇宙将重塑我们的生活,我们要确保它变得更好

College degree want to 0 basic programming after looking for a job feasible?

Exchange 2013 SSL certificate installation document
![[pumpkin Book ml] (task3) decision tree (updating)](/img/4c/fc7157518ad729400d605b811323de.png)
[pumpkin Book ml] (task3) decision tree (updating)

Writing of graph nodes that trigger different special effects during the day and at night in Tiktok

145-keep-alive的初步使用

jenkins多任務並發構建

深入了解-微信开发者工具
随机推荐
Webshell management tool and its traffic characteristics analysis
STM32 concept and installation [day 1]
Graduation design campus information publishing platform website source code
Distributed resource management and task scheduling framework yarn
Preliminary use of 145 keep alive
ASP. Net core write a cache attribute tool
机房建设资料
Mysql database authorization learning
Is software testing still popular in 2022?
什么叫裸写SQL?express操作mysql用什么中件间或插件好呢?
How QT counts the frequency of letters in a string
Construction and test of hfish honey pot
Ora-12899 error caused by nchar character
医院无线网络系统设计
Install SSL Certificate in Litespeed web server
Mysql database UDF authorization learning
深入了解-微信开发者工具
Quick sort considerations
Database design
How to use the directory classification function of the new version of easycvr (v2.5.0)?