[R] Remove spacing at the top and bottom of a plot
David L Carlson
dcarlson at tamu.edu
Sun Sep 24 23:28:45 CEST 2017
The default margins are set as lines below, left, top, and right using mar=c(5.1, 4.1, 4.1, 2.1). Just change the top margin something like 1.1:
par(mfrow=c(1,2), mar=c(5.1, 4.1, 1.1, 2.1))
---------------------------
David L. Carlson
Department of Anthropology
Texas A&M University
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of AbouEl-Makarim Aboueissa
Sent: Sunday, September 24, 2017 3:59 PM
To: R mailing list <r-help at r-project.org>
Subject: [R] Remove spacing at the top and bottom of a plot
Dear All:
Is there is away to remove spacing at the top and the bottom of a plot? If
so, any help will be appreciated.
Please use this code as an example:
par(mfrow=c(1,2))
lizard <- c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5, 8.6,8.8, 8.8,
9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,11.3, 11.9)
n.draw <- 100
mu <- 9
n <- 24
SD <- sd(lizard)
draws <- matrix(rnorm(n.draw * n, mu, SD), n)
get.conf.int <- function(x) {
t.test(x)$conf.int
}
conf.int <- apply(draws, 2, get.conf.int)
plot(range(conf.int), c(0, 1 + n.draw), type = "n", xlab = "mean tail
length", ylab = "sample run")
for (i in 1:n.draw) {
if(conf.int[1,i] <= mu & conf.int[2,i] >= mu ){
#### lines(conf.int[, i], rep(i, 2), lwd = 2, col = 'green')
lines(conf.int[, i], rep(i, 2), lwd = 2)
}
else {
lines(conf.int[, i], rep(i, 2), lwd = 2, col = 'red')
}
}
abline(v = 9, lwd = 3, col='blue') #### lty = 2,
Thank you very much for your help.
with many thanks
abou
______________________
AbouEl-Makarim Aboueissa, PhD
Professor of Statistics
Department of Mathematics and Statistics
University of Southern Maine
[[alternative HTML version deleted]]
______________________________________________
R-help at 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