SlideShare a Scribd company logo
Reference: https://github.com/Ather-Energy/ggTimeSeries
ggplot2 extensions-
ggTimeSeries
prepared by Volkan OBAN
Examples:
devtools::install_github('Ather-Energy/ggTimeSeries')
minimalTheme = theme_set(theme_bw(12))
minimalTheme = theme_update(
axis.ticks = element_blank(),
legend.position = 'none',
strip.background = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
panel.grid = element_blank(),
panel.border = element_blank()
)
set.seed(1)
dtData = data.table(
DateCol = seq(
as.Date("1/01/2014", "%d/%m/%Y"),
as.Date("31/12/2015", "%d/%m/%Y"),
"days"
),
ValueCol = runif(730)
)
dtData[, ValueCol := ValueCol + (strftime(DateCol,"%u") %in% c(6,7) * runif(1) *
0.75), .I]
dtData[, ValueCol := ValueCol + (abs(as.numeric(strftime(DateCol,"%m")) - 6.5)) *
runif(1) * 0.75, .I]
# base plot
p1 = ggplot_calendar_heatmap(
dtData,
'DateCol',
'ValueCol'
)
# adding some formatting
p1 +
xlab(NULL) +
ylab(NULL) +
scale_fill_continuous(low = 'green', high = 'red') +
facet_wrap(~Year, ncol = 1)
# creating some categorical data
dtData[, CategCol := letters[1 + round(ValueCol * 7)]]
# base plot
p2 = ggplot_calendar_heatmap(
dtData,
'DateCol',
'CategCol'
)
# adding some formatting
p2 +
xlab(NULL) +
ylab(NULL) +
facet_wrap(~Year, ncol = 1)
# creating some data
set.seed(1)
dfData = data.frame(x = 1:1000, y = cumsum(rnorm(1000)))
# base plot
p1 = ggplot_horizon(dfData, 'x', 'y')
print("If you're seeing any vertical white stripes, it's a display thing.")
## [1] "If you're seeing any vertical white stripes, it's a display thing."
# adding some formatting
p1 +
xlab(NULL) +
ylab(NULL) +
scale_fill_continuous(low = 'green', high = 'red') +
coord_fixed( 0.5 * diff(range(dfData$x)) / diff(range(dfData$y)))
set.seed(10)
dfData = data.frame(
Time = 1:1000,
Signal = abs(
c(
cumsum(rnorm(1000, 0, 3)),
cumsum(rnorm(1000, 0, 4)),
cumsum(rnorm(1000, 0, 1)),
cumsum(rnorm(1000, 0, 2))
)
),
VariableLabel = c(rep('Class A', 1000), rep('Class B', 1000), rep('Class C',
1000), rep('Class D', 1000))
)
# base plot
p1 = ggplot(dfData, aes(x = Time, y = Signal, group = VariableLabel, fill =
VariableLabel)) +
stat_steamgraph()
# adding some formatting
p1 +
xlab(NULL) +
ylab(NULL) +
coord_fixed( 0.2 * diff(range(dfData$Time)) / diff(range(dfData$Signal)))
Example:
# creating some data
set.seed(1)
dfData = data.frame(Signal = pmax(pmin(rnorm(10000), 3), -3))
dfData2 = data.frame(
Signal = round(head(dfData$Signal, -1),0),
NextSignal = round(tail(dfData$Signal, -1),0),
Weight = 1
)
# base plot
p1 = ggplot(dfData2, aes(xbucket = Signal, ybucket = NextSignal, fill =
NextSignal, weight = Weight) )+
stat_marimekko(color = 'black', xlabelyposition = -0.1)
# adding some formatting
p1 +
xlab('Signal occurrence %') +
ylab('Signal | Next signal occurrence %') +
scale_x_continuous(breaks = 0:10/10) +
scale_y_continuous(breaks = 0:10/10)
ggtimeseries-->ggplot2 extensions

More Related Content

DOCX
imager package in R and examples..
DOCX
Advanced Data Visualization Examples with R-Part II
DOCX
Advanced Data Visualization in R- Somes Examples.
DOCX
Basic Calculus in R.
DOCX
Data Visualization with R.ggplot2 and its extensions examples.
DOCX
R-ggplot2 package Examples
DOCX
ggplot2 extensions-ggtree.
PDF
Some R Examples[R table and Graphics] -Advanced Data Visualization in R (Some...
imager package in R and examples..
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization in R- Somes Examples.
Basic Calculus in R.
Data Visualization with R.ggplot2 and its extensions examples.
R-ggplot2 package Examples
ggplot2 extensions-ggtree.
Some R Examples[R table and Graphics] -Advanced Data Visualization in R (Some...

What's hot (20)

PDF
CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017
PPTX
Introduction to R
PDF
Data visualization using the grammar of graphics
DOCX
CLUSTERGRAM
PDF
Py lecture5 python plots
PDF
Pandas pythonfordatascience
KEY
R meets Hadoop
PDF
Pandas Cheat Sheet
DOCX
Mosaic plot in R.
PPTX
Python programing
KEY
RHadoop の紹介
PPTX
PPT
A Survey Of R Graphics
DOCX
Experement no 6
PDF
Dplyr and Plyr
PDF
Bar plots.ipynb colaboratory
PPTX
Python built in functions
PDF
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
TXT
Mpibhseguranca3
PDF
Effector: we need to go deeper
CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017
Introduction to R
Data visualization using the grammar of graphics
CLUSTERGRAM
Py lecture5 python plots
Pandas pythonfordatascience
R meets Hadoop
Pandas Cheat Sheet
Mosaic plot in R.
Python programing
RHadoop の紹介
A Survey Of R Graphics
Experement no 6
Dplyr and Plyr
Bar plots.ipynb colaboratory
Python built in functions
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
Mpibhseguranca3
Effector: we need to go deeper
Ad

Similar to ggtimeseries-->ggplot2 extensions (20)

PPTX
Python Cheat Sheet Presentation Learning
PDF
User Defined Aggregation in Apache Spark: A Love Story
PDF
User Defined Aggregation in Apache Spark: A Love Story
DOCX
R (Shiny Package) - Server Side Code for Decision Support System
DOCX
A Shiny Example-- R
PDF
Generic Functional Programming with Type Classes
PDF
Refactoring to Macros with Clojure
PDF
Introduction to d3js (and SVG)
PDF
Joclad 2010 d
DOCX
library(sparkline)
PDF
Big Data Analytics with Scala at SCALA.IO 2013
PDF
The Web map stack on Django
PDF
Time Series Analysis and Mining with R
ODP
Clojure basics
PDF
PDF
Time Series Analysis:Basic Stochastic Signal Recovery
PPTX
Googlevis examples
PDF
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
TXT
An example of R code for Data visualization
PPT
SDC - Einführung in Scala
Python Cheat Sheet Presentation Learning
User Defined Aggregation in Apache Spark: A Love Story
User Defined Aggregation in Apache Spark: A Love Story
R (Shiny Package) - Server Side Code for Decision Support System
A Shiny Example-- R
Generic Functional Programming with Type Classes
Refactoring to Macros with Clojure
Introduction to d3js (and SVG)
Joclad 2010 d
library(sparkline)
Big Data Analytics with Scala at SCALA.IO 2013
The Web map stack on Django
Time Series Analysis and Mining with R
Clojure basics
Time Series Analysis:Basic Stochastic Signal Recovery
Googlevis examples
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
An example of R code for Data visualization
SDC - Einführung in Scala
Ad

More from Dr. Volkan OBAN (20)

PDF
Conference Paper:IMAGE PROCESSING AND OBJECT DETECTION APPLICATION: INSURANCE...
PDF
Covid19py Python Package - Example
PDF
Object detection with Python
PDF
Python - Rastgele Orman(Random Forest) Parametreleri
DOCX
Linear Programming wi̇th R - Examples
DOCX
"optrees" package in R and examples.(optrees:finds optimal trees in weighted ...
DOCX
k-means Clustering in Python
DOCX
Naive Bayes Example using R
DOCX
R forecasting Example
DOCX
k-means Clustering and Custergram with R
PDF
Data Science and its Relationship to Big Data and Data-Driven Decision Making
PDF
Scikit-learn Cheatsheet-Python
PDF
Python Pandas for Data Science cheatsheet
PDF
Pandas,scipy,numpy cheatsheet
PPTX
ReporteRs package in R. forming powerpoint documents-an example
PPTX
ReporteRs package in R. forming powerpoint documents-an example
DOCX
R Machine Learning packages( generally used)
DOCX
treemap package in R and examples.
PDF
R-Data table Cheat Sheet
PDF
Rcommands-for those who interested in R.
Conference Paper:IMAGE PROCESSING AND OBJECT DETECTION APPLICATION: INSURANCE...
Covid19py Python Package - Example
Object detection with Python
Python - Rastgele Orman(Random Forest) Parametreleri
Linear Programming wi̇th R - Examples
"optrees" package in R and examples.(optrees:finds optimal trees in weighted ...
k-means Clustering in Python
Naive Bayes Example using R
R forecasting Example
k-means Clustering and Custergram with R
Data Science and its Relationship to Big Data and Data-Driven Decision Making
Scikit-learn Cheatsheet-Python
Python Pandas for Data Science cheatsheet
Pandas,scipy,numpy cheatsheet
ReporteRs package in R. forming powerpoint documents-an example
ReporteRs package in R. forming powerpoint documents-an example
R Machine Learning packages( generally used)
treemap package in R and examples.
R-Data table Cheat Sheet
Rcommands-for those who interested in R.

Recently uploaded (20)

PDF
Business Analytics and business intelligence.pdf
PPTX
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
PPTX
climate analysis of Dhaka ,Banglades.pptx
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PPT
Miokarditis (Inflamasi pada Otot Jantung)
PPT
Quality review (1)_presentation of this 21
PPTX
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
PDF
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
PPT
ISS -ESG Data flows What is ESG and HowHow
PPTX
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
PPTX
Computer network topology notes for revision
PPTX
Database Infoormation System (DBIS).pptx
PDF
annual-report-2024-2025 original latest.
PDF
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
PPT
Reliability_Chapter_ presentation 1221.5784
PPTX
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PDF
Fluorescence-microscope_Botany_detailed content
PPTX
IBA_Chapter_11_Slides_Final_Accessible.pptx
Business Analytics and business intelligence.pdf
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
climate analysis of Dhaka ,Banglades.pptx
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
Miokarditis (Inflamasi pada Otot Jantung)
Quality review (1)_presentation of this 21
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
ISS -ESG Data flows What is ESG and HowHow
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
Computer network topology notes for revision
Database Infoormation System (DBIS).pptx
annual-report-2024-2025 original latest.
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
Reliability_Chapter_ presentation 1221.5784
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
Introduction-to-Cloud-ComputingFinal.pptx
Fluorescence-microscope_Botany_detailed content
IBA_Chapter_11_Slides_Final_Accessible.pptx

ggtimeseries-->ggplot2 extensions

  • 1. Reference: https://github.com/Ather-Energy/ggTimeSeries ggplot2 extensions- ggTimeSeries prepared by Volkan OBAN Examples: devtools::install_github('Ather-Energy/ggTimeSeries') minimalTheme = theme_set(theme_bw(12)) minimalTheme = theme_update( axis.ticks = element_blank(), legend.position = 'none', strip.background = element_blank(), panel.border = element_blank(), panel.background = element_blank(), panel.grid = element_blank(), panel.border = element_blank() ) set.seed(1) dtData = data.table( DateCol = seq( as.Date("1/01/2014", "%d/%m/%Y"), as.Date("31/12/2015", "%d/%m/%Y"), "days" ), ValueCol = runif(730) ) dtData[, ValueCol := ValueCol + (strftime(DateCol,"%u") %in% c(6,7) * runif(1) * 0.75), .I] dtData[, ValueCol := ValueCol + (abs(as.numeric(strftime(DateCol,"%m")) - 6.5)) * runif(1) * 0.75, .I] # base plot p1 = ggplot_calendar_heatmap( dtData, 'DateCol', 'ValueCol' ) # adding some formatting p1 + xlab(NULL) + ylab(NULL) + scale_fill_continuous(low = 'green', high = 'red') +
  • 2. facet_wrap(~Year, ncol = 1) # creating some categorical data dtData[, CategCol := letters[1 + round(ValueCol * 7)]] # base plot p2 = ggplot_calendar_heatmap( dtData, 'DateCol', 'CategCol' ) # adding some formatting p2 + xlab(NULL) + ylab(NULL) + facet_wrap(~Year, ncol = 1)
  • 3. # creating some data set.seed(1) dfData = data.frame(x = 1:1000, y = cumsum(rnorm(1000))) # base plot p1 = ggplot_horizon(dfData, 'x', 'y') print("If you're seeing any vertical white stripes, it's a display thing.") ## [1] "If you're seeing any vertical white stripes, it's a display thing." # adding some formatting p1 + xlab(NULL) + ylab(NULL) + scale_fill_continuous(low = 'green', high = 'red') + coord_fixed( 0.5 * diff(range(dfData$x)) / diff(range(dfData$y)))
  • 4. set.seed(10) dfData = data.frame( Time = 1:1000, Signal = abs( c( cumsum(rnorm(1000, 0, 3)), cumsum(rnorm(1000, 0, 4)), cumsum(rnorm(1000, 0, 1)), cumsum(rnorm(1000, 0, 2)) ) ), VariableLabel = c(rep('Class A', 1000), rep('Class B', 1000), rep('Class C', 1000), rep('Class D', 1000)) ) # base plot p1 = ggplot(dfData, aes(x = Time, y = Signal, group = VariableLabel, fill = VariableLabel)) + stat_steamgraph() # adding some formatting p1 + xlab(NULL) + ylab(NULL) + coord_fixed( 0.2 * diff(range(dfData$Time)) / diff(range(dfData$Signal)))
  • 5. Example: # creating some data set.seed(1) dfData = data.frame(Signal = pmax(pmin(rnorm(10000), 3), -3)) dfData2 = data.frame( Signal = round(head(dfData$Signal, -1),0), NextSignal = round(tail(dfData$Signal, -1),0), Weight = 1 ) # base plot p1 = ggplot(dfData2, aes(xbucket = Signal, ybucket = NextSignal, fill = NextSignal, weight = Weight) )+ stat_marimekko(color = 'black', xlabelyposition = -0.1) # adding some formatting p1 + xlab('Signal occurrence %') + ylab('Signal | Next signal occurrence %') + scale_x_continuous(breaks = 0:10/10) + scale_y_continuous(breaks = 0:10/10)