[R] windrose color ramp issue

Adrienne Wootten amwootte at ncsu.edu
Tue Dec 13 20:05:12 CET 2011


The issue is solved.  For those who wish to use windrose out of the
circular package and have more groups magnitude than they do pedals,
please note the following line in the windrose function -

fill.col = rep(fill.col,length.out=bins) # where bins is the number of
pedals, fill.col is the fill colors for the pedals

This line the function forces the number of colors in the windrose to
be equal to the number of pedals, which frankly makes no sense to me.
I have since fixed the windrose function in the circular package,
replacing the above line with the following:

if(length(fill.col)<J){
	fill.col <- rep(fill.col,length.out=J) # J is the number of groups
}

This correction forces the number of colors to be equal to the number
of groups of magnitudes, when the number of colors is smaller than the
number of groups - otherwise it functions as normal for too many
colors.

This is my correction for issues regarding the number of colors,
submitted so it will hopefully stay in an archive somewhere for the
next person who has this problem.

A

On Tue, Dec 13, 2011 at 12:12 PM, Adrienne Wootten <amwootte at ncsu.edu> wrote:
> An update on this particular problem I've been having.  It seems that
> the number of pedals (the bins argument of the windrose command) is
> somehow effecting the number of colors that will be plotted.  This
> makes no sense since it only controls the number of pedals in the
> windrose not the number of colors.
>
> A
>
> On Mon, Dec 12, 2011 at 4:20 PM, Adrienne Wootten <amwootte at ncsu.edu> wrote:
>> Greetings!
>>
>> I'm having an issue with the windrose produced by the windrose
>> function from the circular package.  For our weather stations in North
>> Carolina I'm helping with a script which takes hourly wind speed and
>> direction data to create windroses for our end users.  One of the
>> stations in the mountains frequently reaches wind speed of 40 to 60
>> mph and in storms can reach wind speed over 80 mph.  This has brought
>> up an issue with the color ramp.
>>
>> Currently the color ramp works one of two ways:
>>
>> #1) Holding the pedal colors fixed:
>>
>> incrspeeds = 2 # fills out the increments argument
>> pedalcolors =  c("darkblue","blue","royalblue","darkturquoise","forestgreen","green","yellowgreen","yellow4","yellow","orange","red","darkred","violetred","mediumorchid","purple")
>>
>> #or 2) Making the pedal colors dynamic based on the increments and the
>> max wind speed.
>>
>> incrspeeds = 2 # fills out the increments argument
>>
>> breaks=seq(0,round(maxwind),incrspeeds) # maxwind is the maximum wind speed
>> numcolors=length(breaks)
>>
>> if(numcolors>length(pedalcolors)){
>> pedalcolors=rev(rainbow(numcolors))
>> }
>>
>> # In either case the result ends up in the wind rose function
>>
>> rose=windrose(wr,breaks=NULL,bins=numpedals,increment=incrspeeds,main=NULL,fill.col=pedalcolors,plot.mids=FALSE,units="degrees",template="geographics",ticks=FALSE,osize=0.05,cir.ind
>> =0.05,cex=0.9,zero=NULL,rotation=NULL,right=FALSE,shrink=NULL,label.freq=TRUE,calm=c("0"),number.calm=TRUE)
>>
>> The issue when there are really large wind speeds in the first case,
>> the windrose wraps the color ramp twice in both the legend and the
>> windrose itself, and then gives only white for the remaining bands of
>> each pedal.  For the second case, when pedalcolors will have the same
>> number of colors as numcolors, the legend has the right color ramp,
>> but the pedals of the windrose don't have all the colors that are
>> passed to it.  Say pedalcolors has 40 colors, which are included in
>> the legend, but the windrose only includes the first 16 colors in
>> pedalcolors.
>>
>> Any thoughts as to why this might be happening in either case?  Thanks!
>>
>> Adrienne
>>
>> --
>> Adrienne Wootten
>> Graduate Research Assistant
>> State Climate Office of North Carolina
>> Department of Marine, Earth and Atmospheric Sciences
>> North Carolina State University
>
>
>
> --
> Adrienne Wootten
> Graduate Research Assistant
> State Climate Office of North Carolina
> Department of Marine, Earth and Atmospheric Sciences
> North Carolina State University



-- 
Adrienne Wootten
Graduate Research Assistant
State Climate Office of North Carolina
Department of Marine, Earth and Atmospheric Sciences
North Carolina State University



More information about the R-help mailing list