r - how to display only the minimum and the maximum values in a legend while using image.plot function -


i using image.plot function display color bar image. color bar, wish display legend @ boundary positions only. however, getting tics @ various places in middle. moreover, corresponding values not getting displayed. please see code segment below:

  color_plate=c('royalblue4','springgreen4','yellow2','darkred')     layout(matrix(c(1,1), 1, 1))     par(mar=c(0,1,1,0)) #here image plotted     image(image_variable, axes=false, xlab="", ylab="",col=color_plate)     image.plot(zlim=c(min(ya),max(ya)),legend.only=true,col=color_plate,     horizontal=true,legend.mar=0.4,legend.shrink=0.4,legend.width=0.4,     axis.args = list(cex.axis = 1.5))  #here color bar added not able generate legend values @ both ends.     #furthermore, wish eliminate tics , need values displayed.                           # tried 2 variations within image.plot function no result: #axis.args = list(cex.axis = 1.5,at=c(floor(min(ya)),ceiling(max(ya)))) #and   #axis.args = list(cex.axis = 1.5, at=c(0.01,0.05),labels=c(0.01,0.05)) 

please suggest suitable modification in segment.

thanks in advance. munish

although can't run example, think mean, , think can tweak layout(..). looking @ ?image.plot, there example want - use breaks argument , lab.breaks argument image.plot:

# generate image_variable demonstration image_variable <- array(runif(100),dim=c(10,10)) color_plate=c('royalblue4','springgreen4','yellow2','darkred')  library(fields) # image.plot # puts colour scale marks within colour bar, not on boundaries: # image.plot(image_variable,col=color_plate,zlim=c(0,1),...)  zlim <- c(0,1) # define colour breaks (they default spaced evenly): brks = seq(0,1,length.out=length(color_plate)+1)  # plot: image.plot(image_variable, zlim=zlim, axes=f,            col=color_plate, breaks=brks, lab.breaks=brks) 

enter image description here

hope that's wanted.

if only want 0 , 1, it's easier:

image.plot(image_variable, col=color_plate, zlim=zlim, axes=f,        axis.args=list(at=zlim, labels=zlim)) 

enter image description here


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -