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-boun...@r-project.org> On Behalf Of John
> Sent: Tuesday, August 18, 2020 8:32 AM
> To: r-help <r-help@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
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to