How to plot TimeSeries? #92
Replies: 9 comments 1 reply
-
Try using scale_x_datetime. At the moment this is the only way to plot time series. The input series can contain millis since Unix epoch. Also accepted Date, Instant and ZonedDateTime from java.time but these values will be converted to millis since Unix epoch. LocalDate, LocalTime and LocalDateTime are not supported. When formatting date-time labels Lets-plot assumes UTC time-zone. |
Beta Was this translation helpful? Give feedback.
-
Thanks @alshan that works great! Another question:
|
Beta Was this translation helpful? Give feedback.
-
Glad it worked for you. Regarding the other questions: To add a title use the ggtitle function. The background gridlines are not there yet but you can generate and style a set of horizontal/vertical lines using geom_hline and geom_vline functions. We don't have the zoom/pan kind of interactivity. The closest thing could be using the xlim or ylim parameters in coord_xxx function (coord_cartesian for example). Perhaps, if ipywidgets are available, a slider can be used to set these values but nobody ever tried this :). |
Beta Was this translation helpful? Give feedback.
-
Thanks! great work team! |
Beta Was this translation helpful? Give feedback.
-
Yes for gridlines, panning/zooming not in the nearest future) |
Beta Was this translation helpful? Give feedback.
-
Thanks again! |
Beta Was this translation helpful? Give feedback.
-
Thanks for the feedback! You can try the plotly.kt - not quite sure but it might have panning/zooming. |
Beta Was this translation helpful? Give feedback.
-
There is a new demo in 1.3.0 with time series on X-axis: https://nbviewer.jupyter.org/github/JetBrains/lets-plot-kotlin/blob/master/docs/examples/jupyter-notebooks/formatting_axes_etc.ipynb |
Beta Was this translation helpful? Give feedback.
-
@wangtieqiao fun hlines(range: IntProgression): Feature {
val horizontalLine: (Int) -> Feature = { yIntercept: Int ->
geom_hline(
yintercept = yIntercept,
alpha = 0.1,
color = GENERAL_MUTED_COLOR,
size = 0.02,
)
}
var horizontalLines: Feature = horizontalLine(range.first)
for (yIntercept: Int in range.first + range.step until range.last step range.step) {
horizontalLines += horizontalLine(yIntercept)
}
return horizontalLines
} It can be used like this: ggplot(dataFrame) + hlines(-110 until 110 step 5) Cheers 😊 |
Beta Was this translation helpful? Give feedback.
-
Is there any example notebook to show how to plot timeseries data with time in X-axis?
X-axis data could be any of the Datetime classes like
LocalDate, LocalDateTime or ZonedDateTime
etcBeta Was this translation helpful? Give feedback.
All reactions