Caption in matplot command

Asked

Viewed 58 times

1

How do I create a legend in the matplot command?

a = rnorm(1000)
b = runif(1000)
matplot(cbind(a, b), type = 'l')
  • 1

    You use the same function as in a plot() normal. Take a look at ?legend.

  • Welcome to Stackoverflow in English. I edited your question to remove the greetings as we usually keep the text as clean as possible to focus on your scheduling question. If you are interested in visiting a part of the site that is not aimed to ask questions can know the [chat]. If you have questions about the operation, rules and procedures of the site visit the [meta] :)

1 answer

1

You can create a caption quickly with the command legend. I made a little caption for the example you quoted:

a = rnorm(1000)
b = runif(1000)
matplot(cbind(a, b), type = 'l', ylim=c(-5,5), main = "Séries",
        xlab = 'dias', ylab='contagens')
legend("topright", legend = c('a', 'b'), col = c('red', 'black'),
       ncol = 2, cex = 1, lwd = 2, text.col = c('red', 'black'))

inserir a descrição da imagem aqui

OBS

The command legend has several options and you can see all the documentation through:

??legend

Browser other questions tagged

You are not signed in. Login or sign up in order to post.