1

My code:

library(vcd)

barplot(as.matrix(data),ylim=c(0,13),main="P wave",
        xlab="number of clusters", ylab="traveltime rms(ms)",
        col=c("red", "black", "green"), beside=TRUE)

legend("topright", 
       legend = c("fcm","gk","gg"), 
       fill = c( "red", "black", "green"))

My data:

    5   6   7
fcm 13.0    12.5    11.8
gk  10.9    10.5    10.2
gg  12.0    11.0    10.8

I got:

Error in plot.new() : figure margins too large

What is wrong with ylim?Is there any chance that I can calculate max from data and use it or...?

Richard Rublev
  • 7,718
  • 16
  • 77
  • 121

2 Answers2

2

Maybe this is of interest for your question? Error in plot.new() : figure margins too large, Scatter plot

Try playing around with these parameters: par(mar=c(1,1,1,1))

In anycase, ylim is the limit of your axis, not of the margins of the figure. The margins are what is AROUND your plot, and with the axis limit you choose how much information should be on your plot :)

Community
  • 1
  • 1
tlorin
  • 1,100
  • 6
  • 17
  • 30
0

I've have run this code

library(vcd)

fcm <-c(13.0,12.5,11.8)
gk  <-c(10.9 ,   10.5  ,  10.2)
gg  <-c(12.0 ,   11.0 ,   10.8)
data <- rbind(fcm,gk,gg)
colnames(data) <- c(5,6,7)

barplot(as.matrix(data),ylim=c(0,13),main="P wave",
        xlab="number of clusters", ylab="traveltime rms(ms)",
        col=c("red", "black", "green"), beside=TRUE)

legend("topright", 
       legend = c("fcm","gk","gg"), 
       fill = c( "red", "black", "green"))

And got this plot. enter image description here

So no problem here. Maybe something you did previously. Have you tried restarting R?

RHA
  • 3,677
  • 4
  • 25
  • 48