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.
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.
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
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
I am plotting date-time vs integer in ZingChart. Even if there is difference of one second or the difference of 1 hour, the width is same between the two points. If the starting time is same as the previous one, like in my attached image at 23:24:40, there should not a white gap in between if it is proper date and time axis. Is there any solution to this problem? You can also view it on alnnovative.com/zing6.php
ZingChart will automatically place values at each index, unless you use key, value pairs as your data points. To do this, set your series object values like so:
"values":[
[1420070400000,50],
[1420071000000,50],
[1420070520000,50],
[1420070640000,50],
[1420070700000,50],
[1420070760000,50],
[1420070820000,50],
[1420070940000,50],
[1420071060000,50]
]
Take a look at this demo. I'm a member of the ZingChart team, let me know if you need more help.
I have a dataset of 2D greyscale images (50 x 50 pixels) taken over a time period. As a means of analysing these images I want to take a slice - the central column of pixels from each image - and 'plot' these as a time series. So that I end up with time on the x-axis, and the column of pixels corresponding to that time vertically above it. (I appreciate this might not be entirely clear, so please let me know if anything needs clarifying).
I'm not sure how this can be achieved in IDL. I can easily pick out the central slice from each image and combine them into a new array, which I then display with TVSCL. This is the sort of thing I'm after, but since the data is not taken at regular time intervals, just bunching it all up into one new image doesn't represent the data properly. I really need a way of displaying the data as a scaled time series.
Can anyone suggest a way of doing this in IDL?
If you need any more details please just let me know.
Thanks
I think you're looking for something similar to a Hovmoller diagram (http://en.wikipedia.org/wiki/Hovm%C3%B6ller_diagram).
Your best bet is probably to use a contour plot, where you can specify the X and Y locations. Something like:
c = CONTOUR(data, time, ylocation)
where data is your 2D array of slices, time is a vector with the time values (which can be irregularly spaced), and ylocation is another vector with the y locations. There are a lot of properties on CONTOUR to control fill/not filled, contour levels, labels, etc.
Hope this helps!
-Chris
It's hard to write without knowing how your data is stored, but let's say you have your images in something like:
images = fltarr(xsize, ysize, ntimes)
times = fltarr(ntimes)
Then you could plot a time series of the values at any pixel x, y with:
plot, times, images[x, y, *]