Re: [R] How to plot a legend centered only on the x axis

2017-05-12 Thread Antonio Silva
Thanks a lot Duncan, Jim and Marc! 2017-05-11 22:59 GMT-03:00 Marc Schwartz : > > Bingo. > > The 'inset' argument is what I was missing. That allows this to be done > with one step, rather than the two that I had. > > Thanks Duncan. > > Mar [[alternative HTML version deleted]] _

Re: [R] How to plot a legend centered only on the x axis

2017-05-11 Thread Marc Schwartz
> On May 11, 2017, at 7:01 PM, Duncan Murdoch wrote: > > On 11/05/2017 2:36 PM, Antonio Silva wrote: >> Hello r-users >> >> I want to plot some barplots inside a looping with the legend placed >> outside the plotting area. >> >> No matter the number of bars I want the legend to be placed cente

Re: [R] How to plot a legend centered only on the x axis

2017-05-11 Thread Duncan Murdoch
On 11/05/2017 2:36 PM, Antonio Silva wrote: Hello r-users I want to plot some barplots inside a looping with the legend placed outside the plotting area. No matter the number of bars I want the legend to be placed centered on the x-axis. See the example below for(i in 1:10) { var_1 <- sample(

Re: [R] How to plot a legend centered only on the x axis

2017-05-11 Thread Jim Lemon
Hi Antonio, First you want the center of the plot: xylim<-par("usr") x_center<-sum(xylim[1:2])/2 Then as you want to have you legend above the plot: # you will probably want to change the "20" to your preference y_bottom<-xylim[4]+diff(xylim[3:4])/20 then: legend(x_center,ybottom,...xjust=0.5,

Re: [R] How to plot a legend centered only on the x axis

2017-05-11 Thread Antonio Silva
Thanks for you attention Mark. Your approach is really very interesting. I will try to apply it in my code. All the best Antonio 2017-05-11 16:19 GMT-03:00 Marc Schwartz : > > > On May 11, 2017, at 1:36 PM, Antonio Silva > wrote: > > > > Hello r-users > > > > I want to plot some barplots insid

Re: [R] How to plot a legend centered only on the x axis

2017-05-11 Thread Marc Schwartz
> On May 11, 2017, at 1:36 PM, Antonio Silva wrote: > > Hello r-users > > I want to plot some barplots inside a looping with the legend placed > outside the plotting area. > > No matter the number of bars I want the legend to be placed centered on the > x-axis. > > See the example below > >

[R] How to plot a legend centered only on the x axis

2017-05-11 Thread Antonio Silva
Hello r-users I want to plot some barplots inside a looping with the legend placed outside the plotting area. No matter the number of bars I want the legend to be placed centered on the x-axis. See the example below for(i in 1:10) { var_1 <- sample(1000:10,sample(3:8,1)) ymax <- max(var_1)