Open marywestwood opened 4 years ago
Looking into that. it looks like two different issues.
regarding issue 1. here is a hint of what probably happens:
df <- data.frame(x=0:24, y= 0:24)
ggplot(df, aes(x,y )) +coord_polar() +
geom_rect(xmin=0, ymin=-5.0, xmax=12, ymax=24, alpha=.1) +
geom_line(colour='blue') +
scale_x_continuous(breaks = 1:4 * 6)
In our case, I think the coordinate of the bottom of the annotations are not calculated properly as the ymin is probably a bit lower than the bottom of the coordinate system...
In this toy pure ggplot example, one can work around this way, using scale_y_continuous
:
ggplot(df, aes(x,y )) +coord_polar() +
geom_rect(xmin=0, ymin=-5.0, xmax=12, ymax=24, alpha=.1) +
geom_line(colour='blue') +
scale_x_continuous(breaks = 1:4 * 6)+
scale_y_continuous(limits=c(-5, NA))
Applied to your example:
c3_polcor <- ggetho(dt, aes(y=as.numeric(activity), fill=as.factor(id)),
time_wrap = 86400,
) +
stat_ld_annotations(height=.1,
alpha=.3,
ypos=.1,
x_limits = c(0, 86400),
outline = NA) +
stat_pop_etho()
c3_polcor + coord_polar() + scale_y_continuous(limits=c(min(dt[,activity]), NA))
It is a little bit of a hack, but that can work for now... Also, note that you can directly use geom_reactangle rather that stat_pop_etho if you are comfortable with it (as there are only two rectangles to draw in your case)... Will follow up on the other part of the issue :smile:
the second point is now a separate issue (#36)
Hello!
I'm having some difficulties with using Rethomics to produce polar coordinate plots. The centre of the plot has a grey circle that coincides with what should be the light phase (the right side of the plot, from 0-12h). Also, the activity appears to not be continuous in that it does not fully close at 0/24 h. I've posted my code below, as well as the polar coordinate plot and actogram I produced using this code. Data and metadata are also attached in a zip (archive.zip). Any advice or help is much appreciated!
Archive.zip