[R] setting the legend scale in contour plots

Uwe Ligges ligges at statistik.tu-dortmund.de
Wed Jan 16 20:27:19 CET 2013



On 16.01.2013 12:00, Sarah Magozzi wrote:
> Hi,
>
> I'd like to compare SST data for year 2000 with SST for year 2001. I managed
> to get filled contour plots showing monthly SST for both years (12 plots for
> each year, 24 plots in total). In order to compare year 2000 and year 2001,
> however, I'd need to have the same legend scale (same color bar) in both
> years plots.
>
> Thus, my question is: is there a way to set the legend scale in contour
> plots?
>
> Considering only year 2000, this is my script:
>
> for (t in 1:12) {
> SSTt[,,t]<-t(SST[,,t])
>
> filled.contour(
>
> x=seq(-180,180, length.out=nrow(SSTt[,,t])), y=seq(-90,90,
> length.out=ncol(SSTt[,,t])), SSTt[,,t],
>
> xlim=range(seq(-180,180, length.out=nrow(SSTt[,,t])), finite=TRUE),
>
> ylim=range(seq(-90,90, length.out=ncol(SSTt[,,t])), finite=TRUE),
>
> zlim=range(SSTt[,,t], finite=TRUE),
>
> levels=pretty(range(SSTt[,,t], finite=TRUE), nlevels), nlevels=25,
>
> color.palette=heat.colors,
>
> col=color.palette(length(pretty(range(SSTt[,,t], finite=TRUE), nlevels),
> nlevels=25)-1),
>
> )
>
> }
>
> When I try to run it, I get this error: Error in n[1L] : object of type
> 'closure' is not subsettable
>
> Could you please tell me what's wrong?


Not likely anybody starts to create a reproducible example to check what 
is going on. The reproducible exampelm is what you should provide. See 
the posting guide.

Best,
Uwe Ligges



> Cheers
>
> Sarah
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list