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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: temp200818.pdf
Type: application/pdf
Size: 214674 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20200818/42c5ce52/attachment.pdf>
"patternbar_s" : show legend and other issues
2 messages · John, 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 <r-help-bounces at r-project.org> On Behalf Of John
Sent: Tuesday, August 18, 2020 8:32 AM
To: r-help <r-help at 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