qmplot(ggmap)
qmplot()所属R语言包:ggmap
Quick map plot
快速图图
译者:生物统计家园网 机器人LoveR
描述----------Description----------
qmplot is the ggmap equivalent to the ggplot2 function qplot and allows for the quick plotting of maps with data/models/etc. qmplot is still experimental.
qmplot是等效的ggmap到的ggplot2的功能qplot,可快速绘制图的数据/模型/等。仍然是实验qmplot。
用法----------Usage----------
qmplot(x, y, ..., data, zoom, source = "stamen",
extent = "device", legend = "right", padding = 0.02,
darken = c(0, "black"), mapcolor = "color",
facets = NULL, margins = FALSE, geom = "auto",
stat = list(NULL), position = list(NULL),
xlim = c(NA, NA), ylim = c(NA, NA), main = NULL,
f = 0.05, xlab = deparse(substitute(x)),
ylab = deparse(substitute(y)))
参数----------Arguments----------
参数:x
longitude values
经度值
参数:y
latitude values
纬度值
参数:...
other aesthetics passed for each layer
通过每一层的其他美学
参数:data
data frame to use (optional). If not specified, will create one, extracting vectors from the current environment.
数据框的使用(可选)。如果未指定,将创建一个,从当前环境中提取向量。
参数:zoom
map zoom, see get_map
图缩放,get_map
参数:source
map source, see get_map
图源,请参阅get_map
参数:extent
how much of the plot should the map take up? 'normal', 'panel', or 'device' (default)
多少的图的图吗? “正常”,“面板”,或“装置”(默认)
参数:legend
'left', 'right' (default), 'bottom', 'top', 'bottomleft', 'bottomright', 'topleft', 'topright', 'none' (used with extent = 'device')
左,右(默认),底部,顶,bottomleft,bottomright“,”左上“,”topright,没有(使用程度=设备)
参数:padding
distance from legend to corner of the plot (used with extent = 'device')
从传说到角落里的图(使用程度=设备的距离)
参数:darken
vector of the form c(number, color), where number is in [0, 1] and color is a character string indicating the color of the darken. 0 indicates no darkening, 1 indicates a black-out.
向量的形式为c(号码,颜色),其中number为[0,1]和颜色是一个字符串,它表示的颜色的变暗。 0表示没有变黑,1表示一个黑。
参数:mapcolor
color ('color') or black-and-white ('bw')
颜色(“色”)或黑色和白色(BW)
参数:facets
faceting formula to use. Picks facet_wrap or facet_grid depending on whether the formula is one sided or two-sided
小面的公式来使用。精选facet_wrap或facet_grid取决于是否计算公式为单面或双面
参数:margins
whether or not margins will be displayed
是否将显示利润
参数:geom
character vector specifying geom to use. defaults to "point"
字符向量,指定GEOM使用。默认为“点”
参数:stat
character vector specifying statistics to use
指定统计使用的字符向量
参数:position
character vector giving position adjustment to use
位置调整使用的字符向量。
参数:xlim
limits for x axis
对于x轴的限制
参数:ylim
limits for y axis
对于y轴的限制
参数:main
character vector or expression for plot title
图标题的字符向量或表达
参数:f
number specifying the fraction by which the range should be extended
数指定分数的范围应该扩大
参数:xlab
character vector or expression for x axis label
矢量字符或表达为x轴的标签
参数:ylab
character vector or expression for y axis label
矢量字符或表达式为y轴的标签
实例----------Examples----------
qmplot(lon, lat, data = crime)
# only violent crimes[只有暴力犯罪]
violent_crimes <- subset(crime,
offense != 'auto theft' &
offense != 'theft' &
offense != 'burglary'
)
# rank violent crimes[排名暴力犯罪]
violent_crimes$offense <-
factor(violent_crimes$offense,
levels = c('robbery', 'aggravated assault',
'rape', 'murder')
)
# restrict to downtown[限制到市中心]
violent_crimes <- subset(violent_crimes,
-95.39681 <= lon & lon <= -95.34188 &
29.73631 <= lat & lat <= 29.78400
)
theme_set(theme_bw())
qmplot(lon, lat, data = violent_crimes, colour = offense, darken = .5,
size = I(3.5), alpha = I(.6), legend = 'topleft')
qmplot(lon, lat, data = violent_crimes, geom = c('point','density2d'))
qmplot(lon, lat, data = violent_crimes) + facet_wrap(~ offense)
qmplot(lon, lat, data = violent_crimes, extent = 'panel') + facet_wrap(~ offense)
qmplot(lon, lat, data = violent_crimes, extent = 'panel', colour = offense) +
facet_wrap(~ month)
# doesn't quite work yet....[不相当的工作......]
qmplot(long, lat, xend = long + delta_long,
yend = lat + delta_lat, data = seals, geom = 'segment')
library(scales)
library(grid)
options('device')$device(width = 4.98, height = 5.97)
qmplot(lon, lat, data = wind, size = I(.5), alpha = I(.5)) +
opts(title = 'NOAA Wind Report Sites')
# thin down data set...[瘦不下来的数据集...]
s <- seq(1, 227, 8)
thinwind <- subset(wind,
lon %in% unique(wind$lon)[s] &
lat %in% unique(wind$lat)[s]
)
# for some reason adding arrows to the following plot bugs[由于某种原因,箭头下面的图形错误]
theme_set(theme_bw(18))
options('device')$device(width = 6.13, height = 7.04)
qmplot(lon, lat, data = thinwind, geom = 'tile', fill = spd, alpha = spd,
legend = 'bottomleft') +
geom_leg(aes(xend = lon + delta_lon, yend = lat + delta_lat)) +
scale_fill_gradient2('Wind Speed\nand\nDirection',
low = 'green', mid = muted('green'), high = 'red') +
scale_alpha('Wind Speed\nand\nDirection', range = c(.1, .75)) +
guides(fill = guide_legend(), alpha = guide_legend())
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|