[R] plotCI linetypes

Jim Lemon drjimlemon at gmail.com
Fri Jul 22 00:36:26 CEST 2016


Hi Florian,
As I suspected, you will have to use something other than the "arrows"
function, which most people use to draw "error bars". This is where
the "lty" argument gets used for all of the lines. You could
substitute a function like this:

foobars<-function(x0,y0,x1,y1,length=0.02,col=par("fg"),
 lty=par("lty"),lwd=par("lwd")) {

 segments(x0,y0,x1,y1,col=col,lty=lty,lwd=lwd)
 capx<-diff(par("usr"))[1]*length
 segments(x1-capx,y1,x1+capx,y1,col=col,lty=1,lwd=lwd)
}

for arrows and then replace calls to "arrows" with calls to "foobars".
Obviously "foobars" will only work for vertical bars, but could easily
be modified to handle horizontal bars. I think that should be all you
need.

Jim


On Thu, Jul 21, 2016 at 10:05 PM, Jim Lemon <drjimlemon at gmail.com> wrote:
> Hi Florian,
> I'll have to think about this one.Neither plotCI (which Ben Bolker
> wrote) nor dispersion (which I wrote) do this at the moment, but
> perhaps I can work out something that won't be too hard to program.
> I'll  get back to you.
>
> JIm
>
>
> On Thu, Jul 21, 2016 at 8:07 PM, Florian Detsch
> <florian.detsch at staff.uni-marburg.de> wrote:
>> Dear Jim,
>>
>> first of all, thanks for your wonderful work on the plotrix package.
>> In plotCI, I wonder if it was possible to control the line types of lines
>> (i.e., the part connecting point symbols with caps) and caps separately?
>> Please consider the following code snippet to clarify my point.
>>
>> ## sample data from ?plotCI
>> set.seed(10)
>> y <- runif(10)
>> err <- runif(10)
>>
>> ## visualize data
>> par(mfrow = c(2, 1))
>> for (lwd in c(2, 1.25))
>>   plotCI(1:10, y, err, slty = 2, lwd = lwd)
>>
>> Using slty = 2 alongside with lwd = 2 results in only half sides of the line
>> caps being drawn. That means, if I wanted to stick with dashed lines, I'd be
>> forced to downregulate lwd e.g. to a value of 1.25 in order to achieve fully
>> drawn caps. Would it be possible to implement something like llty (for line
>> type of lines; which I would then set to 2) and clty (for line type of caps;
>> which I would then set to 1) or is there any other, probably more convenient
>> solution?
>>
>> Best,
>> Florian
>>
>> --
>> Florian Detsch (M.Sc. Physical Geography)
>> Environmental Informatics
>> Department of Geography
>> Philipps-Universität Marburg
>> Deutschhausstraße 12
>> 35032 (parcel post: 35037) Marburg, Germany
>>
>> Phone: +49 (0) 6421 28-25323
>> Web: http://umweltinformatik-marburg.de/en/staff/florian-detsch/
>>



More information about the R-help mailing list