Jianyun Wu
2012-Jun-13 02:45 UTC
[R] adjust space between horizontal legend text in a barplot
Hi All, I produced a barplot and made a horizontal legend below the graph. Because the results are from a survey, there are three levels, namely strongly disagree/disagree, neutral and strongly agree/agree.> rownames(survey)[1] "Strongly disagree/disagree" "Neutral" "Strongly agree/agree"As in the output above, there is a large space between "Neutral" and "Strongly agree/agree". This large space appears in the horizontal legend as well. So is there anyway I can reduce such a large gap in the legend when it is superimposed horizontally? Thanks and Regards Fred [[alternative HTML version deleted]]
Hi, Try this. ? plot(0) ? legend("topright", inset=c(0.2,0),legend=c("Strongly disagree/disagree","Neutral","Strongly agree/agree"), lty=1:3, pch=1:3, x.intersp=2) A.K. ----- Original Message ----- From: Jianyun Wu <jianyun.fred.wu at gmail.com> To: r-help at r-project.org Cc: Sent: Tuesday, June 12, 2012 10:45 PM Subject: [R] adjust space between horizontal legend text in a barplot Hi All, I produced a barplot and made a horizontal legend below the graph. Because the results are from a survey, there are three levels, namely strongly disagree/disagree, neutral and strongly agree/agree.> rownames(survey)[1] "Strongly disagree/disagree" "Neutral"? ? ? ? ? ? ? ? ? ? "Strongly agree/agree"As in the output above, there is a large space between "Neutral" and "Strongly agree/agree". This large space appears in the horizontal legend as well. So is there anyway I can reduce such a large gap in the legend when it is superimposed horizontally? Thanks and Regards Fred ??? [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list 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.
R. Michael Weylandt
2012-Jun-13 04:34 UTC
[R] adjust space between horizontal legend text in a barplot
As noted below: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. For more on how to do that see: i) https://github.com/hadley/devtools/wiki/Reproducibility ii) http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example Michael On Tue, Jun 12, 2012 at 9:45 PM, Jianyun Wu <jianyun.fred.wu at gmail.com> wrote:> Hi All, > > I produced a barplot and made a horizontal legend below the graph. > Because the results are from a survey, there are three levels, namely > strongly disagree/disagree, neutral and strongly agree/agree. > > >> rownames(survey)[1] "Strongly disagree/disagree" "Neutral" ? ? ? ? ? ? ? ? ? ?"Strongly agree/agree" > > > > As in the output above, there is a large space between "Neutral" and > "Strongly agree/agree". > > This large space appears in the horizontal legend as well. > > > > So is there anyway I can reduce such a large gap in the legend when it > is superimposed horizontally? > > > > Thanks and Regards > > > > Fred > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > 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.