Hours on Y-axis ggplot2

Hi !

I'm trying to realise a graph with ggplot2 about bats activity
Bats live the night so my data are during the night. I would like that those are in the middle of my graph and not on the side.

this is my code :

spsol<-ggplot(mydatasol, aes(Date_nuit,Temps))+geom_point(size=0.5) +
scale_y_datetime(labels=function(x) format (x,"%H:%M", tz="UTC"),
date_breaks = '2 hour',expand = c(0,0))+
labs(title="Activité des chauves-souris durant l'année 2020 à Mabompré Nord",
x ="Date", y = "Temps (Heures)")+
scale_x_datetime(date_breaks = "1 month", labels = date_format("%d %b"))

spsol + geom_density_2d_filled(contour_var = "ndensity")+
geom_line(data= H_lev_couch, aes(x= Date, y=Lever du soleil),color="red")+
geom_line(data= H_lev_couch, aes(x= Date, y=Coucher du soleil),color="orange")+

The graph that I want begin around 11AM , pass through midnight and end the next day at 11AM

and this is what I have


Thank you for your answer !

Hello @Mau_W ,

interesting. My first idea is to subtract 11 hours of each data_time value and put that right by changing the labels in scale_y_* .
But I do not know if that works out fine.
Could you provide a small sample of your data in reprex format so that we can play with the data (and possibly this idea)?


All of my coloms are "POSIXct"

Is it enought ?

This is not something I can work with. It is also not an example of data I would like to see in a reprex .
Maybe one of the other forum members is willing to help you out.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.