[R] x-axis in interaction plot is weird

Jinsong Zhao j@zh@o @end|ng |rom ye@h@net
Sat Feb 19 13:46:45 CET 2022


Hi there,

When `xtick = TRUE`, the x-axis in interaction plot is weird:

with(ToothGrowth, {interaction.plot(dose, supp, len, xtick = TRUE)})

you may notice that the x-axis is position at line 1, and the labels at 
line 2.

And when set

par(mgp = c(-4, -2, -1))

The x-axis is also positioned at line 1, but the labels at line -1.

When `xtick = FALSE`, according the source code of interaction.plot(), 
the mgp[2] set to 0, however, the labels is also at line 1 instead of 
line 0.

I don't know whether those behaviors were designed.

Best,
Jinsong

PS:
 > sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936
[2] LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936
[4] LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.936

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_4.1.2 tools_4.1.2



More information about the R-help mailing list