1

It looks like something simple I am missing but have no idea how to deal with this.

So I used a layout() function and I managed to get the layout as I wanted as below picture. Iris data was used in my coding.

enter image description here

Problem is, it does not show me the x label and y label on the output when I use plot() functions after this. And xaxis and yaxis for plot() looks overlapping. I am not sure how to deal with this problem.

There was no problem for x and y labelling before introducing plot.new() and par() to set up the main name of my diagram. (i.e. before I use the code from plot.new() to title(), xlab and ylab were shown)

I used 6 different plots in my original code, including, the plot.new() for title(), but I omitted the rest of them for convenience

enter image description here

Here is my code below,

x <- iris$Sepal.Length
y <- iris$Species


x_min <- min(iris$Sepal.Length)
x_max <- max(iris$Sepal.Length)
y_min <- min(iris$Sepal.Width)
y_max <- max(iris$Sepal.Width)


layout(matrix(c(1,1,1,1,1,1,
            2,2,3,3,4,4,
            5,5,5,6,6,6), nc=6, byrow = TRUE), heights=c(lcm(1),1,1,1,1))
layout.show(6)
par("mar"=c(1,1,1,1,1,1))
plot.new()
plot.window(xlim=c(0,1), ylim=c(0,1))
text(x=0.5,y=0.5,"scatter and density plots for Sepal and Length and Sepal Width" ,font=2, cex=1.5)
plot(...)
neilfws
  • 29,020
  • 5
  • 49
  • 59
G.Lee159
  • 39
  • 5
  • (1) `par(mar=...)` takes a vectof of 4, not 6. (2) You explicitly set the margins to "1" which, in the case of base R plots, typically means the default axis numbers are hidden. (3) If after changing `mar=` you still have questions, it would really help to have some reproducible code (ref: https://stackoverflow.com/questions/5963269/). – r2evans Sep 11 '18 at 02:33
  • If par() function hides the axis, what is the alternative way to use this layout? Because if I leave out par() function, the error says "figure margins are too large" – G.Lee159 Sep 11 '18 at 03:43
  • Do you get the "too large" error on all plots or just the top (`text(...)`) plot? That's the only one that (from the image) I would expect that behavior. Realize that `par(mar=)` is per "pane", so-to-speak, so your plots 2-6 can have different margins. – r2evans Sep 11 '18 at 03:53

0 Answers0