Carter
03/05/2022, 2:22 PMCarter
03/05/2022, 2:28 PMval X = "Time"
val Y = "y"
val rawDataframe: Map<String, List<Any>> = buildMap<String, List<Any>> {
put(X, rawData.map { it.x })
put(Y, rawData.map { it.y })
}
val detectionDataframe: Map<String, List<Any>> = buildMap<String, List<Any>> {
put(X, detection.map { it.x })
put(Y, detection.map { it.y })
}
val plot = letsPlot() + geomLine(rawDataframe, color = "blue") {
x = X
y = Y
} + geomPoint(detectionDataframe, color = "red") {
x = X
y = Y
} + ggtitle(
title
) + ylab(
yAxisLabel
) + scaleXDateTime() + ggsize(
IMAGE_PIXELS_WIDTH,
IMAGE_PIXELS_HEIGHT
)
altavir
03/05/2022, 3:12 PMIgor Alshannikov
03/06/2022, 7:49 PMtime is a Kotlinx Instant and y is a Float.Kotlinx Instant is not currently supported. Please try to convert all 'Instant' values to Double - milliseconds since Unix epoch.
Carter
03/06/2022, 8:35 PMtoEpochMilliseconds
makes it work better.
I’m seeing two weird things though. It seems the x axis labels are repeating (minute is always 2).
And the Y axis doesn’t line up with the data even though the coordinates should be along the line.Carter
03/06/2022, 8:35 PMCarter
03/06/2022, 8:35 PMCarter
03/06/2022, 8:35 PMCarter
03/06/2022, 8:36 PMCarter
03/06/2022, 8:37 PMIgor Alshannikov
03/07/2022, 12:51 AMsampling = samplingNone
parameter to the geomLine()
layer.
Another thought: scaleXTime()
might be a better fit for ECG than scaleXDateTime()
See docs: https://lets-plot.org/kotlin/plot-api/jetbrains.letsPlot.scale/scale-x-time.html
Example notebook: https://nbviewer.org/github/JetBrains/lets-plot-kotlin/blob/master/docs/examples/jupyter-notebooks/scale_time.ipynbCarter
03/07/2022, 12:50 PMsampling = samplingNone
resolves the issue with the points being wrong, so that’s a big help.Carter
03/07/2022, 12:54 PMscaleXDateTime
is probably what I want.
Being able to see the actual wall time is very helpful because I sometimes need to manually correlate the data from multiple sources. being able to say “here’s what happened at noon” is a lot easier than “here’s what happened at time index 52 minutes.”Carter
03/07/2022, 12:55 PMm
in the format and switching to uppercase M
seems to be the right parameter.