在R中删除图形的一部分 [英] removing part of a graphic in R
本文介绍了在R中删除图形的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是从R获得的图片(下面给出代码)。
Here is a picture obtained from R (the code is given below).
我想将其导出为 pdf格式。
但是,我想先删除右侧的图例栏。
However, I'd like first to remove the legend bar on the right.
据我所知,没有可选参数可以控制此酒吧传奇。
As far as I know, there is no optional argument that controls this bar legend.
你会怎么做?
library(gplots)
f <- function(x, y, theta)
{
num <- (x^(-theta) + y^(-theta) - 1)^(-1 / theta)
denom <- x * y
return(num / denom)
}
x <- y <- seq(0.01, 0.18, 0.01)
z <- outer(x, y, FUN=f, theta=2/3)
levels=seq(0, 36, 3)
draw.contour <- function()
{
contour(x=x, y=y, z=z, add=TRUE,
levels=levels,
drawlabels=TRUE,
labcex=0,
xlim=rev(range(x)),
ylim=rev(range(y)))
}
par(mgp=c(2, 0.5, 0))
filled.contour(x=x, y=y, z=z,
levels=levels,
col=colorpanel(length(levels) + 1, "white", "grey10"),
xlim=rev(range(x)),
ylim=rev(range(y)),
plot.axes={axis(1, c(0.18, 0.01), label=TRUE, tcl=-0.5)
axis(2, c(0.18, 0.01), label=TRUE, tcl=-0.5)
draw.contour()},
xlab="x",
frame=FALSE)
mtext(text="y", side=2, line=1.8, las=1)
par(mgp=c(3, 1, 0))
推荐答案
我将按照joran的建议使用 .filled.contour
进行新绘制。
I would make new plot using .filled.contour
as recommended by joran.
例如:
plot(NA,xlim=rev(range(x)),
ylim=rev(range(y)),xlab="x",ylab="y",
frame=FALSE,axes=F,xaxs="i",yaxs="i")
.filled.contour(x=x, y=y, z=z,
levels=levels,
col=colorpanel(length(levels) + 1, "white", "grey10"))
draw.contour()
axis(1, c(0.18, 0.01), label=TRUE, tcl=-0.5)
axis(2, c(0.18, 0.01), label=TRUE, tcl=-0.5, las=1)
制造
这篇关于在R中删除图形的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文