Hi,
I am working on bar plot and legend overlap plot. I attempted all position
like topright, bottomright, topleft and bottomleft still same pblm is there.
par(mar=c(5,22.5,2,2))
barplot(t(data[,2:3]) , beside=TRUE, col=c(rgb(.537, .769, .933),rgb(.059,
.412, .659)), width = 1, horiz=TRUE,cex.names=.9, border ="white",las=1,
cex.axis= 1, cex.lab=1.2,axes = FALSE)
legend("topright", c("legend1","legend2"), cex=1.5, bty="n", fill =
c(rgb(.059, .412, .659),rgb(.537, .769, .933)));
http://r.789695.n4.nabble.com/file/n4638995/Screenshot.png
How can i avoid overlapping of bars and legend?
Regards
--
View this message in context: http://r.789695.n4.nabble.com/How-to-adjust-legend-in-a-plot-tp4638995.html
Sent from the R help mailing list archive at Nabble.com.
How to adjust legend in a plot?
7 messages · Manish Gupta, Pramod, John Kane +1 more
I would suggest the following: 1. Change the margins of the third axis from 5.2 to say 2.5. 2. Reduce the cex in the legend from 1.5 to say 0.75 I think this should work for you. -- View this message in context: http://r.789695.n4.nabble.com/How-to-adjust-legend-in-a-plot-tp4638995p4638996.html Sent from the R help mailing list archive at Nabble.com.
No, My X label are so big so i cannot reduce margin and cex change won't affect it much. Is there any way to write legend first and start plot later. Regards -- View this message in context: http://r.789695.n4.nabble.com/How-to-adjust-legend-in-a-plot-tp4638995p4638997.html Sent from the R help mailing list archive at Nabble.com.
The only way then i believe is to reduce the width of the bars. Make it 0.5 in case if the numbers of variable allows you to do so. -- View this message in context: http://r.789695.n4.nabble.com/How-to-adjust-legend-in-a-plot-tp4638995p4639002.html Sent from the R help mailing list archive at Nabble.com.
I cannot reduce bar width. It is ok for me. Is there any way to merge two plots one with only legend and other with barplot? Regards -- View this message in context: http://r.789695.n4.nabble.com/How-to-adjust-legend-in-a-plot-tp4638995p4639011.html Sent from the R help mailing list archive at Nabble.com.
Just move the legend. Change topright to x = ? y = ? whatever to find an empty place on the plot. John Kane Kingston ON Canada
-----Original Message----- From: mandecent.gupta at gmail.com Sent: Fri, 3 Aug 2012 00:17:38 -0700 (PDT) To: r-help at r-project.org Subject: Re: [R] How to adjust legend in a plot? I cannot reduce bar width. It is ok for me. Is there any way to merge two plots one with only legend and other with barplot? Regards -- View this message in context: http://r.789695.n4.nabble.com/How-to-adjust-legend-in-a-plot-tp4638995p4639011.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.
____________________________________________________________ FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more!
Hi, It would be useful to have more information and a reproducible example. For instance : 1. Why such margin at the left side ? 2. Why do you have the same problem when you plot the legend at the bottom ? Have you tried to define the exact (x,y) location ? 3. Why do you say cex doesn't affect you x-labels ? Regards, Eloi
I am working on bar plot and legend overlap plot. I attempted all position like topright, bottomright, topleft and bottomleft still same pblm is there.
These are not all positions. Tried to define the exact location (x,y)
par(mar=c(5,22.5,2,2))
barplot(t(data[,2:3]) , beside=TRUE, col=c(rgb(.537, .769, .933),rgb(.059,
.412, .659)), width = 1, horiz=TRUE,cex.names=.9, border ="white",las=1,
cex.axis= 1, cex.lab=1.2,axes = FALSE)
legend("topright", c("legend1","legend2"), cex=1.5, bty="n", fill =
c(rgb(.059, .412, .659),rgb(.537, .769, .933)));
What is "data". Please provide a fully reproducible example.
No, My X label are so big so i cannot reduce margin and cex change won't affect it much. Is there any way to write legend first and start plot later.
What are your x-labels ? Why cex doesn't affect it ? Please provide the code you used.
I cannot reduce bar width. It is ok for me. Is there any way to merge two plots one with only legend and other with barplot?
Yes you can plot your graph and the legend in 2 different plot using par(mfrow=(2,1)) #plot first graph #plot legend but the overall size of the graph would be smaller and you just said you don't want to reduce the bar width.... We cannot help you without a fully reproducible example and explanations of the (very picky) limitations you want. Regards, Eloi
On 12-08-02 09:22 PM, Manish Gupta wrote:
No, My X label are so big so i cannot reduce margin and cex change won't affect it much. Is there any way to write legend first and start plot later. Regards -- View this message in context: http://r.789695.n4.nabble.com/How-to-adjust-legend-in-a-plot-tp4638995p4638997.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.
Eloi Mercier Bioinformatics PhD Student, UBC Paul Pavlidis Lab 2185 East Mall University of British Columbia Vancouver BC V6T1Z4