No. 1 如何将色带图例放在“persp"之外?阴谋?;No.2 如何使色带成为标准彩虹? [英] No. 1 How do I put a color ramp legend outside a "persp" plot?; No.2 how can I make the color ramp be the standard rainbow?

查看:54
本文介绍了No. 1 如何将色带图例放在“persp"之外?阴谋?;No.2 如何使色带成为标准彩虹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

# This Script is intended to plot a response surface for River Dissolved Organic Carbon (DOC) Flux and Concentration
# As a function of month of the year and rate of discharge

# Establish x as 1 through 12  (Months)
x <- seq(1, 12, len=12)

# Establish y as 11 evenly spaced levels of Discharge from 5000 to 100,000 cfs 
y <-seq (5000, 100000, len=11)  

# Generate Matrix with data for z (DOC Flux  kg/day)
A=matrix(c(7.82E+04,3.03E+05,5.43E+05,7.81E+05,1.02E+06,1.24E+06,1.46E+06,1.68E+06,1.89E+06,2.09E+06,2.28E+06,7.43E+04,2.89E+05,5.17E+05,7.45E+05,9.68E+05,1.19E+06,1.40E+06,1.61E+06,1.81E+06,2.00E+06,2.19E+06,7.31E+04,2.84E+05,5.10E+05,7.35E+05,9.57E+05,1.17E+06,1.39E+06,1.59E+06,1.79E+06,1.99E+06,2.18E+06,7.46E+04,2.90E+05,5.22E+05,7.53E+05,9.82E+05,1.21E+06,1.43E+06,1.64E+06,1.85E+06,2.05E+06,2.25E+06,7.86E+04,3.06E+05,5.50E+05,7.96E+05,1.04E+06,1.28E+06,1.51E+06,1.74E+06,1.96E+06,2.18E+06,2.39E+06,8.45E+04,3.29E+05,5.92E+05,8.56E+05,1.12E+06,1.37E+06,1.62E+06,1.87E+06,2.11E+06,2.35E+06,2.58E+06,9.06E+04,3.53E+05,6.34E+05,9.17E+05,1.20E+06,1.47E+06,1.74E+06,2.00E+06,2.26E+06,2.51E+06,2.75E+06,9.55E+04,3.71E+05,6.66E+05,9.62E+05,1.25E+06,1.54E+06,1.82E+06,2.09E+06,2.36E+06,2.62E+06,2.87E+06,9.72E+04,3.77E+05,6.76E+05,9.76E+05,1.27E+06,1.56E+06,1.84E+06,2.11E+06,2.37E+06,2.63E+06,2.88E+06,9.52E+04,3.69E+05,6.61E+05,9.52E+05,1.24E+06,1.52E+06,1.79E+06,2.05E+06,2.30E+06,2.55E+06,2.79E+06,9.02E+04,3.49E+05,6.25E+05,9.00E+05,1.17E+06,1.43E+06,1.68E+06,1.93E+06,2.17E+06,2.40E+06,2.62E+06,8.40E+04,3.26E+05,5.83E+05,8.38E+05,1.09E+06,1.33E+06,1.57E+06,1.80E+06,2.02E+06,2.23E+06,2.44E+06), nrow=12, ncol=11, byrow=TRUE)
z<-A  


nrz <- nrow(z)
ncz <- ncol(z)

#Generate a Matrix to plot a fourth Dimension (DOC concentration mg/L)
C=matrix(c(6.39,8.55,9.25,9.53,9.65,9.67,9.65,9.59,9.51,9.43,9.33,6.07,8.13,8.80,9.09,9.21, 9.24,9.22,9.18,9.11,9.04,8.96,5.97,8.01,8.68,8.97,9.10,9.14,9.14,9.10,9.05,8.99,8.92,6.10,8.19,8.88,9.19,9.33,9.39,9.40,9.37,9.33,9.27,9.21,6.43,8.63,9.37,9.71,9.87,9.93,9.95,9.93,9.89,9.84,9.78,6.91,9.28,10.08,10.45,10.62,10.69,10.71,10.69,10.65,10.60,10.54,7.41,9.95,10.80,11.18,11.36,11.44,11.45,11.43,11.38,11.32,11.25,7.81,10.47,11.35,11.74,11.92,11.99,11.99,11.95,11.89,11.82,11.73,7.94,10.64,11.52,11.90,12.07,12.12,12.11,12.06,11.98,11.89,11.78,7.78,10.41,11.26,11.62,11.77,11.81,11.78,11.72,11.63,11.53,11.41,7.37,9.85,10.65,10.98,11.11,11.14,11.11,11.04,10.95,10.84,10.73,6.87,9.18,9.92,10.23,10.35,10.37,10.34,10.27,10.18,10.09,9.98), nrow=12, ncol=11, byrow=TRUE)
d<-C
nrd <-nrow(d)
ncd <-ncol(d)
jet.colors <- colorRampPalette(c("blue", "green"))
nbcol <-100
color <- jet.colors(nbcol)
dfacet <- d[-1, -1] + d[-1, -ncd] + d[-nrd, -1] + d[-nrd, -ncd]
facetcol <- cut(dfacet, nbcol)

# Generate the response surface plot
persp(x, y, z, col=color[facetcol], theta=-60, phi=50,  xlab="Month", ylab="Discharge CFS", zlab="DOC Flux", main="Response Surface Penobscot at Eddington", sub="2011 to 2013, Where Color is indexed to DOC Concentration", ticktype="detailed")

推荐答案

layout 和一个细小的情节:

需要进行一些清理才能去除轴和标签.查看填充轮廓的代码:

Will need some cleanup to get rid of axes and labels. Look at code for filled contour:

layout(matrix(c(1,2),nrow=1), width=c(4,1) )
# your plot code here

#
plot(1,1, xlim=c(0,.21), ylim=c(0,100), type="n", mar=c(0,0,0,0),
   oma=c(0,0,0,0) , axes=FALSE, ylab="", xlab="")
levels<-facetcol; rect(0, levels[-length(facetcol)], 1, levels[-1], col = color)

这篇关于No. 1 如何将色带图例放在“persp"之外?阴谋?;No.2 如何使色带成为标准彩虹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆