[R] "patternbar_s" : show legend and other issues

PIKAL Petr petr@p|k@| @end|ng |rom prechez@@cz
Tue Aug 18 10:37:50 CEST 2020


Hi

Probably patternbar handles legend position in nonstandard way so 
lebend.position does not work as expected.

Rotating % is done by axis.title.y ...
theme(axis.text.x = element_text(angle = 90),
axis.title.y = element_text(angle=0),
aspect.ratio= 0.4)

Legend has to be placed probably by legend.y.pos and legend.x.pos.

patternbar_s(df_c_m, x,y, group, xlab='', ylab='%', label.size=3,
pattern.type=c( 'hlines','nwlines', 'crosshatch'),
pattern.line.size=c(5, 5, 5),frame.size=0.2,
pixel=16, density=c(18, 30, 50),frame.color='black',
legend.label=c("up", "uc", "dn" ), bar.width=0.8,
legend.y.pos = .49, legend.x.pos = 1.1) +
scale_y_continuous(limits = c(0, 150.2))

Cheers
Petr

> -----Original Message-----
> From: R-help <r-help-bounces using r-project.org> On Behalf Of John
> Sent: Tuesday, August 18, 2020 8:32 AM
> To: r-help <r-help using r-project.org>
> Subject: [R] "patternbar_s" : show legend and other issues
>
> Hi
>
>    Thanks for help from people on this forum. My graph (made with
> patternbar_s) is attached.
>
> (1) How should I place my legend under the graph? I have "
> ,legend.position="bottom"" in my theme, but it does not seem to work.
> (2) How may I rotate the y label ("%")?
>
> *****
> Code:
> *****
> x<- factor(df_c_m$date)
> df_c_m[,"date"]<-x
> y<-df_c_m$percentage
> group <- df_c_m$direction
> patternbar_s(df_c_m, x,y, group, xlab='', ylab='%', label.size=3, 
> pattern.type=c(
> 'hlines','nwlines', 'crosshatch'), pattern.line.size=c(5, 5, 
> 5),frame.size=0.2,
>              pixel=16, density=c(18, 30, 50),frame.color='black',
>               legend.label=c("up", "uc", "dn" ),
>              bar.width=0.8)+scale_y_continuous(limits = c(0, 
> 100.2))+ggtitle('')+
> theme(axis.text.x = element_text(angle = 90), aspect.ratio= 0.4
> ,legend.position="bottom")
> *****
> data: attached


More information about the R-help mailing list