Dear R-ians,
I have a question concerning plotting different plots on one figure. I
have written a script to plot an image, a legend (based on different
rectangles) and a timeseries plot on one figure.
In my R-lagnuage it looks like this (without arguments that are not
usefull for my question):
#---> I first define the functions
image.data<-function(...){
....
#-->Plot the data
par(fig=c(0,1,0.25,1),new=TRUE)
par(pin=c(1.5,(num.y/num.x*1.5)))
image(c(1:(num.x+1)),c(1:(num.y+1)),output.matrix,xlab="X
coord",ylab="Y coord",main='NDVI',las =1,cex.axis=0.7, cex.lab=0.7,
col=topo.colors(255), asp=1)
#---> Add a legend (colored rectangles) + legend axis (=values)
par(fig=c(0,1,0.3,0.4),new=TRUE)
plot.window(xlim = c(0,1), ylim = c(0,1), yaxs="i")
rect((1:254)/255,0,(2:255)/255,0.1,col=topo.colors(255),border=FALSE)
axis(1,padj=-1,cex.axis=0.7)
...
}
profile.data<-function(...){
...
#-->Plot the data
par(fig=c(0,1,0,0.3),new=TRUE)
par(pin=c(1.5,num.y/num.x*0.5))
plot(NDVI, type="l",cex.axis=0.7, cex.lab=0.7)
...
}
When I subsequently use the functions I get problems with the legend. It
plots my image nice in the upper part of my pixture, adds the
timeseries below, but it does not plot the rectangles of the legend. I
don't know what I do wrong, because it plots perfectly the axis of the
legend, but the colorbar is invisible. All suggestions would be wonderfull!
Thanx in advance,
Stef
Multi-figure plotting
2 messages · Stefaan Lhermitte, Uwe Ligges
1 day later
Stefaan Lhermitte wrote:
Dear R-ians,
I have a question concerning plotting different plots on one figure. I
have written a script to plot an image, a legend (based on different
rectangles) and a timeseries plot on one figure.
In my R-lagnuage it looks like this (without arguments that are not
usefull for my question):
#---> I first define the functions
image.data<-function(...){
....
#-->Plot the data
par(fig=c(0,1,0.25,1),new=TRUE)
par(pin=c(1.5,(num.y/num.x*1.5)))
image(c(1:(num.x+1)),c(1:(num.y+1)),output.matrix,xlab="X
coord",ylab="Y coord",main='NDVI',las =1,cex.axis=0.7, cex.lab=0.7,
col=topo.colors(255), asp=1)
#---> Add a legend (colored rectangles) + legend axis (=values)
par(fig=c(0,1,0.3,0.4),new=TRUE)
plot.window(xlim = c(0,1), ylim = c(0,1), yaxs="i")
rect((1:254)/255,0,(2:255)/255,0.1,col=topo.colors(255),border=FALSE)
axis(1,padj=-1,cex.axis=0.7)
...
}
profile.data<-function(...){
...
#-->Plot the data
par(fig=c(0,1,0,0.3),new=TRUE)
par(pin=c(1.5,num.y/num.x*0.5))
plot(NDVI, type="l",cex.axis=0.7, cex.lab=0.7)
...
}
When I subsequently use the functions I get problems with the legend. It
plots my image nice in the upper part of my pixture, adds the
timeseries below, but it does not plot the rectangles of the legend. I
don't know what I do wrong, because it plots perfectly the axis of the
legend, but the colorbar is invisible. All suggestions would be wonderfull!
I guess it is either clipped or there is not enough space left in the plot region. But since the example is not directly reproducable, I cannot tell you (well, I don't want to waste time to make your example reproducible for me, that's your job!). Uwe Ligges
Thanx in advance, Stef
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html