Format time series in lattice

Bryan

I often deal with time series data with timescales of years, months, days, minutes, and seconds. When plotting, it would be convenient to easily change the way the time series axes are displayed, along the lines of a strptime command.

library(lattice)
t_ini = "2013-01-01"
ts = as.POSIXct(t_ini)+seq(0,60*60*24,60*60)
y = runif(length(ts))
# default plot with time series axis in M D h:m 
xyplot(y~ts) 
# this attempt at using format to display only hours on the x-axis does not work:
xyplot(y~ts, scales=list(x=list(labels=format("%H")))) 

There seems to be a format command in the scales argument, but I can't seem to get the hang of it. Any ideas? Thanks!
Bryan

IRTFM
xyplot(y~ts, scales=list(x=list(at= as.numeric(ts), 
                                labels=format(ts, "%H"))))

To make the ticks every six hours you just use seq.POSIXt:

xyplot(y~ts, scales=list(
     x=list(at= seq(as.POSIXct(t_ini), by="6 hour", length=5), 
     labels=format(seq(as.POSIXct(t_ini), by="6 hour", length=5),
                   "%H hrs"))
      )    

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Convert time series format

From Dev

Time Series hourly data format

From Dev

format a time series as dataframe with julian date

From Dev

format a time series as dataframe with julian date

From Dev

Convert /reshape a dataset from 'wide to long' format and convert the time column into time format for time-series analysis

From Dev

Change scale format for y axis in lattice plot

From Dev

Prepare Time Series for Machine Learning - Long to Wide Format

From Dev

matplotlib: plot milliseconds time series in human readable format

From Dev

Chart with time series using Rickshaw. format of input data

From Dev

How to draw time series plot for data in date format in R

From Dev

how to format data to make it time series data in R

From Dev

Transforming date format in R to something more manageable for time series data?

From Dev

Time series data in long format, coalesce specific rows timepoints while ignoring others for each participant

From Dev

D3.js - Plotting time series data - Format x-axis from JSON

From Dev

How to sort a Pandas Time Series containing values in 12 hour (AM/PM) format

From Dev

time series plot with x axis ticks in month-year format in R

From Dev

Subsetting zoo series by a time that is not in the series

From Dev

split a time series by another irregular time series

From Dev

Time series forecasting in R, univariate time series

From Dev

Updating time series with another time series

From Dev

Time series - correlation and lag time

From Dev

Time series - correlation and lag time

From Dev

ElasticSearch for Time Series Data

From Dev

Binning time series with pandas

From Dev

MongoDB Time Series Aggregation

From Dev

Resample on time series data

From Java

Dataframe time series transpose

From Dev

Correlate time series with Graphite

From Dev

Time Series from spectrum

Related Related

  1. 1

    Convert time series format

  2. 2

    Time Series hourly data format

  3. 3

    format a time series as dataframe with julian date

  4. 4

    format a time series as dataframe with julian date

  5. 5

    Convert /reshape a dataset from 'wide to long' format and convert the time column into time format for time-series analysis

  6. 6

    Change scale format for y axis in lattice plot

  7. 7

    Prepare Time Series for Machine Learning - Long to Wide Format

  8. 8

    matplotlib: plot milliseconds time series in human readable format

  9. 9

    Chart with time series using Rickshaw. format of input data

  10. 10

    How to draw time series plot for data in date format in R

  11. 11

    how to format data to make it time series data in R

  12. 12

    Transforming date format in R to something more manageable for time series data?

  13. 13

    Time series data in long format, coalesce specific rows timepoints while ignoring others for each participant

  14. 14

    D3.js - Plotting time series data - Format x-axis from JSON

  15. 15

    How to sort a Pandas Time Series containing values in 12 hour (AM/PM) format

  16. 16

    time series plot with x axis ticks in month-year format in R

  17. 17

    Subsetting zoo series by a time that is not in the series

  18. 18

    split a time series by another irregular time series

  19. 19

    Time series forecasting in R, univariate time series

  20. 20

    Updating time series with another time series

  21. 21

    Time series - correlation and lag time

  22. 22

    Time series - correlation and lag time

  23. 23

    ElasticSearch for Time Series Data

  24. 24

    Binning time series with pandas

  25. 25

    MongoDB Time Series Aggregation

  26. 26

    Resample on time series data

  27. 27

    Dataframe time series transpose

  28. 28

    Correlate time series with Graphite

  29. 29

    Time Series from spectrum

HotTag

Archive