pbreheny / visreg

Visualization of regression functions
http://pbreheny.github.io/visreg/
62 stars 18 forks source link

Errors when plot size and margins reduced #60

Closed Derek-Jones closed 6 years ago

Derek-Jones commented 6 years ago

If the following code is called at the end of this script, the data is here.

visreg2d(spec_mod, "Processor.MHz", "mem_rate", plot.type="persp")

the message: "Error in .External.graphics(...)" appears. Sometimes the message is: "Error in plot.new() : figure margins too large"

The size of the plot and the margins are reduced. See the file ESEUR_config.r

Everything works if the plot size and margins are no changed.

pbreheny commented 6 years ago

This depends on the size of the graphics window and the size of your margins. Your example ran without any errors on my machine. Either increase the height/width of the device you're trying to plot to, or decrease the margins with par(mar=c(...)); this is not a visreg issue.

Derek-Jones commented 6 years ago

Looked at the source of the package.

plot.type="image" calls filled.contour, which is restricted to full size pages.

plot.type="persp" supports smaller plots, it's just a matter of finding values for par's mar and oma options.

pbreheny commented 6 years ago

Right, and I'll admit that filled.contour and persp are not the easiest functions to work with. But I didn't write them -- I'm just providing an interface to them.

Derek-Jones commented 6 years ago

The lattice package supports levelplot and contourplot functions.

I don't know if they are viable alternatives for the visreg use-case, but I have fond them to be flexible and support more options.

pbreheny commented 6 years ago

That's a good suggestion, I'll have to look into it. visreg does not currently support it, although it does support level/contour plots using ggplot2; see #37.