"patternbar_s" : show legend and other issues

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

"patternbar_s" : show legend and other issues

miao
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

______________________________________________
[hidden email] 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.

temp200818.pdf (286K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: "patternbar_s" : show legend and other issues

PIKAL Petr
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 <[hidden email]> On Behalf Of John
> Sent: Tuesday, August 18, 2020 8:32 AM
> To: r-help <[hidden email]>
> 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

______________________________________________
[hidden email] 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.