b4154
b4154

Reputation: 383

barplot: How to get the labels of y-axis outside the y-axis and the box, created with box()?

Bar plot looks in PDF file strange. Code:

pdf("fileName2.pdf", width=100, height=75)
par(resetPar())
par(mar=c(30, 150, 7, 7), lwd=2)
barplot(as.numeric(c(2, 4, 1, 6)), col = c("lightblue"), main="Bar plot",
        names.arg=c("This is \nbar 2...1","This is bar 2...2",
        "This is bar 2...3","This is bar 2...4"), , xpd=TRUE, las=1, lwd=3,
        horiz=TRUE, axes=TRUE, axis.lty=1, space=1, cex.axis=22, cex.names=22)
box(which="plot", lty="solid")#lty = '1373'
dev.off()

Question: How to get the labels (1 to 15) of y-axis (here it is x-axis because horiz=TRUE) outside the box?

Upvotes: 1

Views: 211

Answers (1)

Roman
Roman

Reputation: 17648

Your pdf is really large, as width and height are specified in inches. Also your cex parameters are large. Your code with smaller parameters plots everything fine:

pdf(fileName2.pdf",width = 12) par(mar=c(4,10,4,1),cex=2, lwd=2)      
barplot(as.numeric(c(2, 4, 1, 6)), col = c("lightblue"), main="Bar plot",
names.arg=c("This is \nbar 2...1","This is bar 2...2", 
"This is bar 2...3","This is bar 2...4"), las=1,horiz=TRUE, axes=TRUE) 
box(which="plot", lty="solid") 
dev.off() 

Upvotes: 1

Related Questions