Description Usage Arguments Details Value Author(s) Examples
General Plotly method only working on time series data
1 2 |
tsdata |
A vector or a data frame contains information of time series dataset(i.e. created by |
NEWtitle |
title for this plot |
Ylab |
label of Y axis |
Xlab |
label of X axis |
Unit |
the unit of time for the time series data |
ts_name |
a vector contains names for each time line |
title_size |
size of the title |
COLO |
a vector contains colors for each time line |
The function TSplot
is based on package plotly
. It applies plot_ly
function to create
interactive plot for time series data(i.e data generated by function ts
).
a plot result created by plot_ly() function
SOCR team <http://socr.umich.edu/people/>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | require(forecast)
require(dcemriS4)
require(plotly)
## In the "fMRI" chapter, we have a 4-dimension dataset
## with x,y,z and time dimension (dataset "fMRIVolume").
## So we can settle x,y,and z to determine a vector of time series data.
# You could find the raw "fMRIVolume" dataset on the SOCR website
fMRIURL <- "http://socr.umich.edu/HTML5/BrainViewer/data/fMRI_FilteredData_4D.nii.gz"
fMRIFile <- file.path(tempdir(), "fMRI_FilteredData_4D.nii.gz")
download.file(fMRIURL, dest=fMRIFile, quiet=TRUE)
fMRIVolume <- readNIfTI(fMRIFile, reorient=FALSE)
# Load three time series data(with a wrong format)
xA_fMRI_1D_x20_y20_z11 <- fMRIVolume[20, 20, 11, ]
xB_fMRI_1D_x30_y30_z13 <- fMRIVolume[30, 30, 13, ]
xC_fMRI_1D_x40_y40_z12 <- fMRIVolume[40, 40, 12, ]
# Change this to time series data
TS1<-ts(xA_fMRI_1D_x20_y20_z11,start=0,frequency =1/3)
TS2<-ts(xB_fMRI_1D_x30_y30_z13,start=0,frequency =1/3)
TS3<-ts(xC_fMRI_1D_x40_y40_z12,start=0,frequency =1/3)
# Package them into a data frame
TSDF<-data.frame(TS1,TS2,TS3)
# Using this function to create plot
GTSplot(TSDF,Xlab="Time(second)",Unit="sec",ts_name=c("xA_fMRI_1D_x20_y20_z11",
"xB_fMRI_1D_x30_y30_z13","xC_fMRI_1D_x40_y40_z12"),
COLO=c("green","red","blue"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.