0

I have a question in relation to 'lattice' graphics contour plots. I have been trying to create a contourplot using the code below, and am running into an issue with the display ranges. Basically, the contourpplot function uses the ranges for my response(z) variable, ABSerror.

However, the plotted data does not ever reach these 'min,max' limits as they are averaged by the predictor variables (hour, weekday). Is it possible to calculate the display range for lattice graphs and set these as the new limits for the colour legend? I don't want to set absolute limits for the z vector as this would make the code less robust, and would need to change every time I run it.

    contourplot(ABSerror ~ hour * weekday, 
        data = SummaryData,
        cuts = 20,
        labels=TRUE,
        contour=FALSE,
        region = TRUE,
        xlab = "Hour of Day",
        ylab = "Day of Week",
        col.regions=colorRampPalette(c("blue","yellow","red")),
        main = "ABS error")

If necessary, I can try to make the data available online to better explain what I am trying to achieve.

EDIT: More Information

I've now made my code available online here: http://danielcoakley.com/projects/energy-simulation/

The dataset I am using can be found here: SummaryData

Here is the graph I'm getting. As you can see, the data does not reach the ranges shown in the legend. I'm still not sure how this can be fixed.

ABSerror http://danielcoakley.com/project/Model/Current%20Model/Results/ABSerror.png

1 Answers1

1

All lattice functions use prepanel.XXX to determine the limits; for the contourplot, this is prepanel.default.levelplot. Just type this string, and you will see the default implementation. If you are not happy with it, change the code by defining a new function, and pass it as prepanel=prepanel.my.levelplotwith contourplot.

If you want a running code example, please do not forget to make your example self-contained by providing sample data.

Dieter Menne
  • 10,076
  • 44
  • 67
  • Thank you for your comments. I ran the command you specified, 'prepanel.default.levelplot' but did not see the ability to change z-limits. I've just hosted all of my code online to make it easier to go through changes and answer queries (see above) – Daniel Coakely Oct 24 '13 at 02:19