[R] Space between axis title and tick labels in persp plot in R (using vis.gam)

Uwe Ligges ||gge@ @end|ng |rom @t@t|@t|k@tu-dortmund@de
Thu Jul 7 12:42:28 CEST 2022


R does not provide a native 3D coordinate syytem in base graphics. 
Therefore, persp() is rather a hack that plots everything based on its 
internal code into the device.
Labels are not in the marhings of the 2D coordinate system, hence the 
related par() are not functional.

I'd suggest to add the axis titles manually after the plot and keep the 
rest unless you want to look fpr alternatives to persp().

Best,
Uwe Ligges

On 06.07.2022 19:22, jade.shodan--- via R-help wrote:
> Dear list,
> 
> I am making a perspective plot of my generalised additive model (GAM)
> named a1b, using vis.gam() in mgcv, which in turn makes use of the
> persp function in base R.
> 
> Code is as follows:
> 
> library(mgcv)
> vis.gam(x = a1b,
>          view = c("wbgt_max", "lag"),
>          plot.type = "persp",
>          xlab = "max WBGT (°C)",
>          ylab = "lag (days)",
>          zlab = "deaths",
>          theta = 60,
>          phi = 15,
>          r = sqrt(3),
>          d = 1,
>          type = "response",
>          ticktype = "detailed")
> 
> The plot can be found here:
> https://stackoverflow.com/questions/72884763/space-between-axis-title-and-tick-labels-in-persp-plot-in-r-using-vis-gam
> 
> On the x and z-axes, the axis title and axis labels are plotted over each other.
> 
> 
> I would like to:
> 
> 1) increase the space between the axis titles and the tick labels for
> the x and z- axes (WBGT and deaths) and
> 2) increase the space between the ticks and the tick labels.
> 
> I've looked up similar posts on StackOverflow, which suggest adding
> the following code to the plot (and change the values for the
> currently stated defaults):
> 
> par(mgp=c(3,1,0))
> 
> like
> 
> library(mgcv)
> par(mgp=c(20,20,20))
> vis.gam(x = a1b,
>          view = c("wbgt_max", "lag"),
>          etc.
> 
> However, this changes nothing at all to the plot. (I tried with c(20,
> 20, 20) , smaller values and larger ones).
> 
> Would be grateful for any suggestions!
> 
> Jade
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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