Skip to content

Commit

Permalink
replaced rbokeh by plotly/ggplot2
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed May 25, 2020
1 parent 954c795 commit 2082c51
Show file tree
Hide file tree
Showing 9 changed files with 255 additions and 235 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ inst/examples
^docs$
^pkgdown$
^cran-comments\.md$
^CRAN-RELEASE$
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Package: antaresViz
Type: Package
Title: Antares Visualizations
Version: 0.15.1
Version: 0.15.1.900
Authors@R: c(
person("Veronique", "Bachelier", email = "[email protected]", role = c("aut", "cre")),
person("Jalal-Edine", "Zawam", role = "aut"),
person("Francois", "Guillem", role = "aut"),
person("Benoit", "Thieurmel", email = "[email protected]", role = "aut"),
person("Benoit", "Thieurmel", role = "aut"),
person("Titouan", "Robert", role = "aut"),
person("Baptiste", "Seguinot", role = "ctb"),
person("RTE", role = "cph")
Expand Down Expand Up @@ -47,12 +47,12 @@ Imports:
assertthat,
rAmCharts,
utils
RoxygenNote: 7.0.2
RoxygenNote: 7.1.0
Suggests:
testthat,
covr,
rhdf5 (>= 2.20.2),
rbokeh,
ggplot2,
knitr,
visNetwork
VignetteBuilder: knitr
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by roxygen2: do not edit by hand
# Generated by roxygen2: do not edit by hand

S3method(plot,antaresData)
S3method(plot,list)
Expand Down
331 changes: 171 additions & 160 deletions NEWS → NEWS.md

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions R/plot_XY.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# Copyright © 2016 RTE Réseau de transport d’électricité

#' Plot density between X et Y with rbokeh
#' Plot density between X et Y with ggplot2 and plotly
#'
#' This function take somes arguments from rbokeh and make plot.
#'
#' @param data \code{data.frame} can be antaresData object
#' @param x \code{character}, x variable
#' @param y \code{character}, y variable
#' @param precision \code{numeric} precision for plot
#' @param sizeOnCount \code{boolean}, should addapt size of object based on count
#' @param outLine \code{boolean}, add outline on your shape
#' @param transform \code{funciton}, transform function apply on count (by cells), can be log
#' @param precision Deprecated.
#' @param sizeOnCount Deprecated.
#' @param outLine Deprecated.
#' @param transform Deprecated.
#'
#' @examples
#' \dontrun{
Expand All @@ -30,20 +29,21 @@
#' }
#'
#' @export
plotXY <- function(data, x, y, precision = 30, sizeOnCount = FALSE, outLine = TRUE,
transform = NULL)
{
if(!requireNamespace("rbokeh")){
stop("You should install 'rbokeh' library")
plotXY <- function(data, x, y,
precision = 30,
sizeOnCount = FALSE,
outLine = TRUE,
transform = NULL) {
if(!requireNamespace("ggplot2")) {
stop("You should install 'ggplot2' library")
}
if(!"data.frame"%in%class(data)){
if(!"data.frame" %in% class(data)) {
stop("data should be a data.frame")
}

suppressWarnings(p <- rbokeh::figure() %>%
rbokeh::ly_hexbin(x, y, data, xbins = precision,
style = ifelse(sizeOnCount,"lattice", "colorramp"),
palette = c("Spectral10"), line = !outLine, trans = transform))

p
p <- ggplot2::ggplot(data, ggplot2::aes(x = !!ggplot2::sym(x), y = !!ggplot2::sym(y))) +
ggplot2::geom_hex() +
ggplot2::scale_fill_distiller(palette = "Spectral") +
ggplot2::theme_minimal() +
ggplot2::labs(fill = "Density")
plotly::ggplotly(p)
}
34 changes: 21 additions & 13 deletions R/stack_prod.R
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,17 @@ prodStack <- function(x,
# main <- paste0("Tirage ", mcYear)
# }
# }

names(stackOpts$variables) <- sapply(names(stackOpts$variables), function(x){
.getColumnsLanguage(x, language)
})
names(stackOpts$lines) <- sapply(names(stackOpts$lines), function(x){
.getColumnsLanguage(x, language)
})
# browser()
if (!is.null(stackOpts$variables)) {
names(stackOpts$variables) <- sapply(names(stackOpts$variables), function(x){
.getColumnsLanguage(x, language)
})
}
if (!is.null(stackOpts$lines)) {
names(stackOpts$lines) <- sapply(names(stackOpts$lines), function(x){
.getColumnsLanguage(x, language)
})
}

p <- try(.plotProdStack(dt,
stackOpts$variables,
Expand Down Expand Up @@ -734,12 +738,16 @@ prodStackLegend <- function(stack = "eco2mix",

stackOpts <- .aliasToStackOptions(stack)

names(stackOpts$variables) <- sapply(names(stackOpts$variables), function(x){
.getColumnsLanguage(x, language)
})
names(stackOpts$lines) <- sapply(names(stackOpts$lines), function(x){
.getColumnsLanguage(x, language)
})
if (!is.null(stackOpts$variables)) {
names(stackOpts$variables) <- sapply(names(stackOpts$variables), function(x){
.getColumnsLanguage(x, language)
})
}
if (!is.null(stackOpts$lines)) {
names(stackOpts$lines) <- sapply(names(stackOpts$lines), function(x){
.getColumnsLanguage(x, language)
})
}

tsLegend(
labels = c(names(stackOpts$variables), names(stackOpts$lines)),
Expand Down
38 changes: 19 additions & 19 deletions man/limitSizeGraph.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions man/plotXY.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions man/runAppAntaresViz.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2082c51

Please sign in to comment.