R dygraph with the stepPlot option displays steps in a style "horizontal, then vertical" (equivalent to direction = "hv" in ggplot2 geom_step). My data are the result of some aggregation, e.g. apply.monthly (ts, mean), which outputs the monthly means of a time series. The time stamp (index) of the resulting time series represents the endpoints of the time intervals (which makes sense). However, when plotting in dygraph, the steps go horizontal first, then up, displaying the monthly mean of the previous month. As a workaround, I shifted the time stamps using time(ts)= floor_date(time(ts),unit="month"), which corrects the plotting issue, but I feel this is not elegant, since it is a change of the time series and maybe other functions on the time series will be affected. And my data are not small enough to keep copies in different formats.
Did I miss an option in dygraph?
Thanks,
Josef
Related
I have a software build that is taking much longer to complete, and I'd like to find out where the build is spending most of its time. I have approx 4,500 timestamps in the format 2022-06-10T10:27:47.775-04:00.
There's no other data, just the timestamps, and I'm at a loss what terms to search for or even what type of chart to use.
This is the chart I came up with:
To get that chart, I pulled unique entries from the series of timestamps, and plotted them on both the X and Y axes. It does at least show where there were larger jumps in time.
I have an issue, which I feel should be really easy to solve, however I am unable to figure it out.
I have two arrays of equal length, one containing some measurement values and another one containing the time stamps of this measurements as strings in the form of hh:mm:ss (for example: time = ['09:17:12', '09:17:13', '09:17:17', ..., '12:49:02']. The time stamps are not equally separated in time, sometimes they differ by a second, sometimes by 5 seconds. Both arrays are very long - around 100 000 entries.
I would like to plot the measurement values on the y axis against the time stamp values on the x axis. Additionally I would like the formatter on the x axis to show the time every hour (or two hours) in order to avoid overlapping.
I've spent quite a long time trying to figure out how to do it, and I assume it should be fairly straightforward, however I am unable to do it. I guess it should involve datetime, date2num, as well as fiddling with the x axis formatter and locator. If anyone has any suggestions it would be greatly appreciated.
I've created a time series plot in R using the ggplot package, but I wanted to see if I could further customize it by creating target zones. I originally started with an Excel plot that allows me to move a gray box to different areas of the plot as an easier way to point out a range of temperatures. However, I wanted to see if I could replicate this in R. Here's a screenshot of my Excel plot to better explain my goal: Time Series on Excel. On the time series plot, you can see a gray box that you can drag around and change the size of to better define a range of temperatures (in this case, it covers from 15-25C). Is this possible to do on top of my time series plot in R? I'm only starting to code in R so it's been quite hard for me to navigate, and I appreciate any help I could get. Thanks!
I have drawn a dygraph in R. But the time tags in the x axis are different from the actual time values in the data. The problem can be seen clearly in the attached image above- Code and Plot.
The documentation for dygraphs states that "By default dygraphs displays time-series using the time zone of the client workstation." Based off your plot I'm guessing your client (the local environment) is 6 hours or so from UTC, which is measured in London. Maybe when you plot the dygraph you could try this:
dygraph(series) %>%
dyOptions(useDataTimezone = TRUE)
Let me know if that works.
I realize there have been previous questions on how to plot time on the x-axis in ggplot2 but I have looked at those threads and still cannot fix my problem. I have a data set where I measured body temperature of a bird at the same times over several months. I have averaged the body temp at each time to get one 24 hour trace of body temperature.
I have converted my time vector to POSIXct using this code:
rcnj.tb$Time=as.POSIXct(rcnj.tb$Time,format="%H:%M:%S",tz="Africa/Johannesburg")
I then plotted my figure using this code:
ggplot(bird550,aes(Time,Tb)) + geom_line()
to get this figure.Tb trace averaged across time
However, I do not want the date shown but just the time. The time shown is correct although I would like it on a different scale. So I tried this code to get rid of the date and change the scale
last_plot()+scale_x_datetime(labels=date_format("%H:%M")),
breaks = date_breaks("2 hour"),
minor_breaks=date_breaks("1 hour"))
This resulted in this figureTb trace with date removed
However, the scale is wrong now because it should go from 00:00 to 00:00, like in the first graph. So, for my actual question, how can I remove the date component from my first graph to get an x-axis with just time starting at 00:00 and ending at 00:00.
It would appear that ggplot2 is shifting my scale by two hours so I've tried using different time zones because I saw one post mention that. I've also messed around with strftime. I'm wondering if it isn't a limits issue where I need to set a specific limit?
Thanks for any advice