diff --git a/.Rbuildignore b/.Rbuildignore index e64a321..bea1205 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -8,3 +8,4 @@ inst/examples ^docs$ ^pkgdown$ ^cran-comments\.md$ +^CRAN-RELEASE$ diff --git a/DESCRIPTION b/DESCRIPTION index 9d56f33..00ab724 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 = "veronique.bachelier@rte-france.com", role = c("aut", "cre")), person("Jalal-Edine", "Zawam", role = "aut"), person("Francois", "Guillem", role = "aut"), - person("Benoit", "Thieurmel", email = "benoit.thieurmel@datastorm.fr", role = "aut"), + person("Benoit", "Thieurmel", role = "aut"), person("Titouan", "Robert", role = "aut"), person("Baptiste", "Seguinot", role = "ctb"), person("RTE", role = "cph") @@ -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 diff --git a/NAMESPACE b/NAMESPACE index cfd9552..cf16d0a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/NEWS b/NEWS.md similarity index 91% rename from NEWS rename to NEWS.md index 2d18bfe..857dd98 100644 --- a/NEWS +++ b/NEWS.md @@ -1,160 +1,171 @@ -Copyright © 2016 RTE Réseau de transport d’électricité - -Changes in version 0.15.0 (2018-09-28) - -NEW FEATURES: -* In prodStack(), exchangesStack(), tsPlot() and plotMap() it is now possible to compare several studies with a reference. A new 'refStudy' parameter can be used to set the reference study. -* runAppAntaresViz() we can use a reference study with all manipulateWidget modules. - -BUGFIXES: -* prodStack() and exchangesStack() were not working correctly with a list of antaresData or antaresDataList, only one legend was working when the interactive parameter was set to FALSE. -* plotMap() was not working correctly with a list of optsH5, the first graph was not updated correctly when the interactive parameter was set to TRUE. - -Changes in version 0.14.0 (2018-06-12) - -NEW FEATURES: -* In prodStack(), exchangesStack() and tsPlot(), it is now possible to save a plot as PNG or HTML. - -Changes in version 0.13.0 (2018-05-03) - -NEW FEATURES: -* In runAppAntaresViz(), prodStack(), exchangesStack() and tsPlot(), it is now possible to change the language from 'en' to 'fr'. -* prodStack() and exchangesStack() can now represent annual data. -* In plotMap(), it is now possible to give an alias to the parameter "size". A user can specify a new alias with the function setAlias() of 'antaresRead'. -* tsPlot() can now plot several mcYear for several variables. - -BUGFIXES: -* plotMap() was not working with 'leaflet' version 2.0.0. - - -Changes in version 0.12.0 (2017-12-14) - -NEW FEATURES: -* plot(), prodStack(), exchangesStack(), plotMap() work with studies in h5. -* new function runAppAntaresViz(). -* new function plotThermalGroupCapacities(). -* new function limitSizeGraph(). -* new function plotXY(). -* new function modXY(). -* new function stackMap(). -* new option stepPlot in plot(), prodStack() and exchangesStack(). - - -Changes in version 0.11 (2017-07-17) - -NEW FEATURES: -* In plotMap(), it is now possible to represent areas with polygons instead of circles. To do see, user needs to provide a SpatialPolygonsDataFrame object to function mapLayout(). He is then able to interactively set associations between an area and a polygon. - -BUGFIXES: -* Hour was not correctly printed in some charts. -* It was not possible anymore to choose a specific Monte-Carlo scenario in plotMap() when interactive = FALSE. -* Non numeric columns were not correcly handled by plotMap(). -* Heatmaps were not correctly displayed in comparison mode. - -Changes in version 0.10 (2017-06-20) - -BREAKING CHANGES: -* Function plotMapOptions() has lost some parameters of little use and has gained new ones. This may break some scripts. - -NEW FEATURES: -* Comparison mode: All functions can now be used to compare two or more antaresData objects. It is also possible to use a single antaresData object but to compare multiple charts with different parameters. - -BUGFIXES: -* mapLayout() was containing references to the deprecated 'mapStudio' package. This causes a crash on computers where this package has not been installed when it was alive. - - -Changes in version 0.9 (2017-05-31) - -NEW FEATURES: -* plotMap() can now export animated maps. -* It is now possible to set minimal and maximal size of labels in maps. -* plotMap() can now bind non-numeric columns to the color of areas and links. -* It is now possible to set the size of plots in Rmarkdown documents with "runtime:shiny" - -BUGFIXES: -* plotMap(interactive=TRUE) now works in Rmarkdown documents with "runtime:shiny" - - -Changes in version 0.8 (2017-04-07) - -NEW FEATURES: -* All visualisation functions now accept synthetic and detailed data. A new parameter "mcYear" permits to choose whether to view averaged data or a given Monte-Carlo scenario. -* plotMap() now always uses the absolute value of variable 'FLOW LIN.' to avoid any confusion. Direction of flows are represented with arrows. -* plotMap() can now also represent categorical variables. -* It is now possible to use custom color palette for continuous color scales in maps and heatmaps. -* In heatmaps, the y-axis now contains month names instead of week ids. Moreover the info displayed when hovering data has been improved. -* exchangesStack() can now also represent exchanges with rest of the world (column 'ROW BAL.'). -* A new function called setInteractivity() has been added to globally turn off or turn on interactive mode. - -BUGFIXES: -* In plotMap(), several parameters were not working in non-interactive mode. -* In plotMap(), some links were not displayed if the associated values were small. -* Numbers are now correctly rounded on popups and legend in plotMap(). -* Invalid date/hours were displayed on charts due to problems of timezone. -* It was not possible to change width and height of heatmaps. - - -Changes in version 0.7 (2017-02-23) - -NEW FEATURES: -* plot() method can now generate heatmaps. -* plot() method has a new parameter "aggregate" to choose whether to visualize individual plots or aggregated plot. -* plotMap() can now display labels. This may require to increase area size so there is enough place for labels. - -BUGFIXES: -* Many small problems detected by R CMD CHECK have been solved. - - -Changes in version 0.6 (2017-01-23) - -BREAKING CHANGES: -* productionStack and has been renamed prodStack. - -NEW FEATURES: -* plotMap() can now use pie charts, bar charts and polar area charts to represent multiple variables. -* plotMap() can now represent average values on the whole period instead of representing only a single time step. -* plotMap() can now display labels on areas. This feature is still experimental for now and will be improved in next versions. -* It is now possible to choose which variables are displayed in popups in maps created with plotMap(). -* It is now possible to manually set break points for color scales in maps thourgh parameter "options" of plotMap. -* plot() method for antaresDataTable can now output monotone, density and cululated distribution. -* There is now a plot() method for antaresDataList objects. -* It is now possible to register custom production stack aliases with function 'setProdStackLegend'. New aliases are then available in prodStack(). -* The package now also provides a plot method for antaresDataList objects. - -BUGFIXES: -* plot() was not working with annual data. - -Changes in version 0.5 (2016-11-14) - -NEW FEATURES: -* plotMap() can now represent only areas and/or links. It is not necessary anymore to import both to create a map. -* plotMap() can now represent multiple variables with barcharts. A new option is available to choose whether to use the same scale for different variables or one scale per variable. -* plotMap() now displays a nice and clear legend. -* It is now possible to add a title to a map. -* plotMap() has a new parameter "options". With this parameter, user can modify many graphical parameters like colors, size of elements, parameters to construct color scales, etc. -* It is now possible to use a custom base map imported with package "sp". So an internet connection is not necesary anymore to display a nice map. -* When user clicks on a link or an area in a map, a popup appears and display values of the variables represented. - - -Changes in version 0.4 (2016-10-06) - -BREAKING CHANGES: -* add a file LICENSE and copyright to sources files - - -Changes in version 0.3 (2016-09-27) - -NEW FEATURES: -* New function exchangesStack to draw the exchanges of an area with its neighbours -* New function mapLayout that helps the user to bind areas of an antares study with geographical coordinates. The function launches an interactive widget where the user can place and move areas. -* New plot method for objects return by mapLayout(). It generates an interactive map that represents the network of an antares study. -* New function plotMap to visualize the results of an Antares simulation on a map. -* All functions have gained new arguments to control graphical parameters like title, axis label, colors, width and height. -* All functions that produce time series (stacked or not) now produce a beautiful and very clear legend. -* Time series plots (stacked or not) can share a unique legend. When they do, their zoom is synchronised: if the users zooms on one graphic, the zoom is also applied to the other graphics. This can be very helpful in shiny application or interactive documents produced with Rmarkdown. - -Changes in version 0.2 (2016-08-22) - -NEW FEATURES: -* plot method for antaresTable objects and productionStack have an improved interface that helps user choose what he wants to visualize. -* plot method for antaresTable objects can now draw time series but also barplots and monotones. \ No newline at end of file +Copyright © 2016 RTE Réseau de transport d’électricité + + +# antaresViz 0.15.2 (2020-05-26) + +* Fixed CRAN errors. Replaced {rbokeh} dependency by {plotly} + {ggplot2}. + + +# antaresViz 0.15.0 (2018-09-28) + +NEW FEATURES: +* In prodStack(), exchangesStack(), tsPlot() and plotMap() it is now possible to compare several studies with a reference. A new 'refStudy' parameter can be used to set the reference study. +* runAppAntaresViz() we can use a reference study with all manipulateWidget modules. + +BUGFIXES: +* prodStack() and exchangesStack() were not working correctly with a list of antaresData or antaresDataList, only one legend was working when the interactive parameter was set to FALSE. +* plotMap() was not working correctly with a list of optsH5, the first graph was not updated correctly when the interactive parameter was set to TRUE. + + +# antaresViz 0.14.0 (2018-06-12) + +NEW FEATURES: +* In prodStack(), exchangesStack() and tsPlot(), it is now possible to save a plot as PNG or HTML. + + +# antaresViz 0.13.0 (2018-05-03) + +NEW FEATURES: +* In runAppAntaresViz(), prodStack(), exchangesStack() and tsPlot(), it is now possible to change the language from 'en' to 'fr'. +* prodStack() and exchangesStack() can now represent annual data. +* In plotMap(), it is now possible to give an alias to the parameter "size". A user can specify a new alias with the function setAlias() of 'antaresRead'. +* tsPlot() can now plot several mcYear for several variables. + +BUGFIXES: +* plotMap() was not working with 'leaflet' version 2.0.0. + + +# antaresViz 0.12.0 (2017-12-14) + +NEW FEATURES: +* plot(), prodStack(), exchangesStack(), plotMap() work with studies in h5. +* new function runAppAntaresViz(). +* new function plotThermalGroupCapacities(). +* new function limitSizeGraph(). +* new function plotXY(). +* new function modXY(). +* new function stackMap(). +* new option stepPlot in plot(), prodStack() and exchangesStack(). + + +# antaresViz 0.11 (2017-07-17) + +NEW FEATURES: +* In plotMap(), it is now possible to represent areas with polygons instead of circles. To do see, user needs to provide a SpatialPolygonsDataFrame object to function mapLayout(). He is then able to interactively set associations between an area and a polygon. + +BUGFIXES: +* Hour was not correctly printed in some charts. +* It was not possible anymore to choose a specific Monte-Carlo scenario in plotMap() when interactive = FALSE. +* Non numeric columns were not correcly handled by plotMap(). +* Heatmaps were not correctly displayed in comparison mode. + + +# antaresViz 0.10 (2017-06-20) + +BREAKING CHANGES: +* Function plotMapOptions() has lost some parameters of little use and has gained new ones. This may break some scripts. + +NEW FEATURES: +* Comparison mode: All functions can now be used to compare two or more antaresData objects. It is also possible to use a single antaresData object but to compare multiple charts with different parameters. + +BUGFIXES: +* mapLayout() was containing references to the deprecated 'mapStudio' package. This causes a crash on computers where this package has not been installed when it was alive. + + +# antaresViz 0.9 (2017-05-31) + +NEW FEATURES: +* plotMap() can now export animated maps. +* It is now possible to set minimal and maximal size of labels in maps. +* plotMap() can now bind non-numeric columns to the color of areas and links. +* It is now possible to set the size of plots in Rmarkdown documents with "runtime:shiny" + +BUGFIXES: +* plotMap(interactive=TRUE) now works in Rmarkdown documents with "runtime:shiny" + + +# antaresViz 0.8 (2017-04-07) + +NEW FEATURES: +* All visualisation functions now accept synthetic and detailed data. A new parameter "mcYear" permits to choose whether to view averaged data or a given Monte-Carlo scenario. +* plotMap() now always uses the absolute value of variable 'FLOW LIN.' to avoid any confusion. Direction of flows are represented with arrows. +* plotMap() can now also represent categorical variables. +* It is now possible to use custom color palette for continuous color scales in maps and heatmaps. +* In heatmaps, the y-axis now contains month names instead of week ids. Moreover the info displayed when hovering data has been improved. +* exchangesStack() can now also represent exchanges with rest of the world (column 'ROW BAL.'). +* A new function called setInteractivity() has been added to globally turn off or turn on interactive mode. + +BUGFIXES: +* In plotMap(), several parameters were not working in non-interactive mode. +* In plotMap(), some links were not displayed if the associated values were small. +* Numbers are now correctly rounded on popups and legend in plotMap(). +* Invalid date/hours were displayed on charts due to problems of timezone. +* It was not possible to change width and height of heatmaps. + + +# antaresViz 0.7 (2017-02-23) + +NEW FEATURES: +* plot() method can now generate heatmaps. +* plot() method has a new parameter "aggregate" to choose whether to visualize individual plots or aggregated plot. +* plotMap() can now display labels. This may require to increase area size so there is enough place for labels. + +BUGFIXES: +* Many small problems detected by R CMD CHECK have been solved. + + +# antaresViz 0.6 (2017-01-23) + +BREAKING CHANGES: +* productionStack and has been renamed prodStack. + +NEW FEATURES: +* plotMap() can now use pie charts, bar charts and polar area charts to represent multiple variables. +* plotMap() can now represent average values on the whole period instead of representing only a single time step. +* plotMap() can now display labels on areas. This feature is still experimental for now and will be improved in next versions. +* It is now possible to choose which variables are displayed in popups in maps created with plotMap(). +* It is now possible to manually set break points for color scales in maps thourgh parameter "options" of plotMap. +* plot() method for antaresDataTable can now output monotone, density and cululated distribution. +* There is now a plot() method for antaresDataList objects. +* It is now possible to register custom production stack aliases with function 'setProdStackLegend'. New aliases are then available in prodStack(). +* The package now also provides a plot method for antaresDataList objects. + +BUGFIXES: +* plot() was not working with annual data. + + +# antaresViz 0.5 (2016-11-14) + +NEW FEATURES: +* plotMap() can now represent only areas and/or links. It is not necessary anymore to import both to create a map. +* plotMap() can now represent multiple variables with barcharts. A new option is available to choose whether to use the same scale for different variables or one scale per variable. +* plotMap() now displays a nice and clear legend. +* It is now possible to add a title to a map. +* plotMap() has a new parameter "options". With this parameter, user can modify many graphical parameters like colors, size of elements, parameters to construct color scales, etc. +* It is now possible to use a custom base map imported with package "sp". So an internet connection is not necesary anymore to display a nice map. +* When user clicks on a link or an area in a map, a popup appears and display values of the variables represented. + + +# antaresViz 0.4 (2016-10-06) + +BREAKING CHANGES: +* add a file LICENSE and copyright to sources files + + +# antaresViz 0.3 (2016-09-27) + +NEW FEATURES: +* New function exchangesStack to draw the exchanges of an area with its neighbours +* New function mapLayout that helps the user to bind areas of an antares study with geographical coordinates. The function launches an interactive widget where the user can place and move areas. +* New plot method for objects return by mapLayout(). It generates an interactive map that represents the network of an antares study. +* New function plotMap to visualize the results of an Antares simulation on a map. +* All functions have gained new arguments to control graphical parameters like title, axis label, colors, width and height. +* All functions that produce time series (stacked or not) now produce a beautiful and very clear legend. +* Time series plots (stacked or not) can share a unique legend. When they do, their zoom is synchronised: if the users zooms on one graphic, the zoom is also applied to the other graphics. This can be very helpful in shiny application or interactive documents produced with Rmarkdown. + + +# antaresViz 0.2 (2016-08-22) + +NEW FEATURES: +* plot method for antaresTable objects and productionStack have an improved interface that helps user choose what he wants to visualize. +* plot method for antaresTable objects can now draw time series but also barplots and monotones. diff --git a/R/plot_XY.R b/R/plot_XY.R index 39839e4..c8cfe06 100644 --- a/R/plot_XY.R +++ b/R/plot_XY.R @@ -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{ @@ -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) } diff --git a/R/stack_prod.R b/R/stack_prod.R index 7e4d81b..65d4a90 100644 --- a/R/stack_prod.R +++ b/R/stack_prod.R @@ -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, @@ -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)), diff --git a/man/limitSizeGraph.Rd b/man/limitSizeGraph.Rd index a0e32f4..2cf7be4 100644 --- a/man/limitSizeGraph.Rd +++ b/man/limitSizeGraph.Rd @@ -1,20 +1,20 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/limitSizeGraph.R -\name{limitSizeGraph} -\alias{limitSizeGraph} -\title{Use to change limit size of graph (in Mb)} -\usage{ -limitSizeGraph(size) -} -\arguments{ -\item{size}{\code{numeric} widget size autorized in modules (default 200)} -} -\description{ -Use to change limit size of graph (in Mb) -} -\examples{ -\dontrun{ -limitSizeGraph(500) -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/limitSizeGraph.R +\name{limitSizeGraph} +\alias{limitSizeGraph} +\title{Use to change limit size of graph (in Mb)} +\usage{ +limitSizeGraph(size) +} +\arguments{ +\item{size}{\code{numeric} widget size autorized in modules (default 200)} +} +\description{ +Use to change limit size of graph (in Mb) +} +\examples{ +\dontrun{ +limitSizeGraph(500) +} + } diff --git a/man/plotXY.Rd b/man/plotXY.Rd index bb7583f..d13aa2d 100644 --- a/man/plotXY.Rd +++ b/man/plotXY.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/plot_XY.R \name{plotXY} \alias{plotXY} -\title{Plot density between X et Y with rbokeh} +\title{Plot density between X et Y with ggplot2 and plotly} \usage{ plotXY( data, @@ -21,16 +21,16 @@ plotXY( \item{y}{\code{character}, y variable} -\item{precision}{\code{numeric} precision for plot} +\item{precision}{Deprecated.} -\item{sizeOnCount}{\code{boolean}, should addapt size of object based on count} +\item{sizeOnCount}{Deprecated.} -\item{outLine}{\code{boolean}, add outline on your shape} +\item{outLine}{Deprecated.} -\item{transform}{\code{funciton}, transform function apply on count (by cells), can be log} +\item{transform}{Deprecated.} } \description{ -This function take somes arguments from rbokeh and make plot. +Plot density between X et Y with ggplot2 and plotly } \examples{ \dontrun{ diff --git a/man/runAppAntaresViz.Rd b/man/runAppAntaresViz.Rd index 9fc99a6..1fc6537 100644 --- a/man/runAppAntaresViz.Rd +++ b/man/runAppAntaresViz.Rd @@ -1,14 +1,14 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/runApp.R -\name{runAppAntaresViz} -\alias{runAppAntaresViz} -\title{Run app antaresViz} -\usage{ -runAppAntaresViz() -} -\value{ -an App Shiny. -} -\description{ -\code{runAppAntaresViz} run antaresViz App. +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/runApp.R +\name{runAppAntaresViz} +\alias{runAppAntaresViz} +\title{Run app antaresViz} +\usage{ +runAppAntaresViz() +} +\value{ +an App Shiny. +} +\description{ +\code{runAppAntaresViz} run antaresViz App. }