我正在尝试用一些学校创建一个简单的ggmap.我可以轻松地将学校显示为地图上的点(下面的代码).但是,我想带一个学校图标的图像来代替点.
据我所知,annotation_custom不起作用,因为它需要笛卡尔坐标.插图应该有用,但这会为一所学校带来形象,而不是全部.再次尝试将点角色更改为图像,而不仅仅是添加图像.
我怀疑答案在于grImport,subplot以及可能与geom_point对话的功能.但是,我不知所措.
这是一种图像类型,可以作为一个图标:维基媒体毕业帽
这个问题的答案ggplot2中的刻度标记图像可以很好地添加图像,但是,我想将图像用作点字符,并能够根据属性更改颜色,大小等.
# Load needed packages
# install.packages(c("rgdal", "rgeos", "maptools", "ggmap", "sp", "plyr", "XML", "grImport"))
library(rgdal)
library(rgeos)
library(maptools)
library(ggmap)
library(sp)
library(plyr)
library(XML)
library(grImport)
# Define a value for the Seattle Public Schools (SPS) url:
SPSurl <- "http://www.seattleschools.org/modules/cms/pages.phtml? pageid=197023&sessionid=95b8499fc128fde5d7e1335751c73fee&t"
# All of the addresses for SPS, multiple tables:
SPSaddresses <- readHTMLTable(SPSurl)
# Just elementary schools
SPSelementary <- readHTMLTable(SPSurl, which=3, header=T)
# Just keep the names of the schools and addresses
SPSelementary <- SPSelementary[,c(1,3)] …Run Code Online (Sandbox Code Playgroud) 我已经在R(Windows,Rstudio)中安装了Ghostscript和grImport。我正在学习本教程,但我立即收到错误消息,
> library(grImport)
Loading required package: grid
Loading required package: XML
> PostScriptTrace("petal.ps")
Error in PostScriptTrace("petal.ps") :
status 127 in running command 'gswin32c.exe -q -dBATCH -dNOPAUSE -sDEVICE=ps2write -sOutputFile=C:\Users\UsrNm\AppData\Local\Temp\RtmpsXXlWA\file1b5c623f48de -sstdout=petal.ps.xml capturepetal.ps'
In addition: Warning message:
running command 'gswin32c.exe -q -dBATCH -dNOPAUSE -sDEVICE=ps2write -sOutputFile=C:\Users\UsrNm\AppData\Local\Temp\RtmpsXXlWA\file1b5c623f48de -sstdout=petal.ps.xml capturepetal.ps' had status 127
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激。
我想使用存储在外部文件(例如 SVG)中的矢量图形作为图中的绘图符号ggplot2。例如,按照 grImport vignette 中的示例(图 8)https://cran.r-project.org/web/packages/grImport/vignettes/import.pdf
此示例导入自定义 shapefile,然后使用lattice例如绘制它
xyplot(V8 ~ V7, data = flower, xlab = "Height",
ylab = "Distance Apart",
panel = function(x, y, ...) {
grid.symbols(PSflower, x, y, units = "native",
size = unit(5, "mm"))})
Run Code Online (Sandbox Code Playgroud)
grid.symbols()来自grImport包并且是PSflower由 . 在别处导入的 Picture 对象grImport。
该ggimage包接近执行此操作,但它将图像转换为绘图下方的光栅,这是我试图避免的。
有什么方法可以实现类似的东西ggplot2吗?
标记