From 6841feffe102419fe09a5f7121b122c884a21a0e Mon Sep 17 00:00:00 2001 From: lrennels Date: Mon, 20 May 2019 15:36:09 -0700 Subject: [PATCH] Chnage name of explore method for single plot --- docs/src/tutorials/tutorial_1.md | 4 ++-- docs/src/tutorials/tutorial_3.md | 4 ++-- docs/src/userguide.md | 4 ++-- src/explorer/explore.jl | 4 ++-- test/test_explorer.jl | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/src/tutorials/tutorial_1.md b/docs/src/tutorials/tutorial_1.md index e8262c5e8..49965e9b8 100644 --- a/docs/src/tutorials/tutorial_1.md +++ b/docs/src/tutorials/tutorial_1.md @@ -106,14 +106,14 @@ Alternatively, in order to view just one parameter or variable, call the functio ```julia using VegaLite run(m) -p = explore(m, component1, parameter1) +p = Mimi.plot(m, component1, parameter1) save("MyFilePath.svg", p) ``` More specifically for our tutorial use of FUND, try: ```julia using VegaLite -p = explore(m, :socioeconomic, :income) +p = Mimi.plot(m, :socioeconomic, :income) save("MyFilePath.svg", p) ``` diff --git a/docs/src/tutorials/tutorial_3.md b/docs/src/tutorials/tutorial_3.md index 1dded0adf..4b1fb7d91 100644 --- a/docs/src/tutorials/tutorial_3.md +++ b/docs/src/tutorials/tutorial_3.md @@ -81,7 +81,7 @@ We can now use Mimi to construct a model that binds the `grosseconomy` and `emis * If any variables of one component are parameters for another, [`connect_param!`](@ref) is used to couple the two components together. In this example, _YGROSS_ is a variable in the `grosseconomy` component and a parameter in the `emissions` component. The syntax is `connect_param!(model_name, :component_name_parameter, :parameter_name, :component_name_variable, :variable_name)`, where `:component_name_variable` refers to the component where your parameter was initially calculated as a variable. * Finally, the model can be run using the command `run(model_name)`. * To access model results, use `model_name[:component, :variable_name]`. -* To observe model results in a graphical form , [`explore`](@ref) as either `explore(model_name)` to open the UI window, or use `explore(model_name, :component_name, :variable_name)` or `explore(model_name, :component_name, :parameter_name)` to plot a specific parameter or variable. +* To observe model results in a graphical form , [`explore`](@ref) as either `explore(model_name)` to open the UI window, or use `Mimi.plot(model_name, :component_name, :variable_name)` or `Mimi.plot(model_name, :component_name, :parameter_name)` to plot a specific parameter or variable. ```julia @@ -128,7 +128,7 @@ run(m) m[:emissions, :E] # Plot model results -explore(m, :emissions, :E) +Mimi.plot(m, :emissions, :E) # Observe all model result graphs in UI explore(m) diff --git a/docs/src/userguide.md b/docs/src/userguide.md index e51f41415..a6afdfb34 100644 --- a/docs/src/userguide.md +++ b/docs/src/userguide.md @@ -159,12 +159,12 @@ run(mymodel) ![Explorer Model Example](figs/explorer_model_example.png) -Alternatively, in order to view just one parameter or variable, call the function `explore` as below to return a plot object and automatically display the plot in a viewer, assuming `explore` is the last command executed. This call will return the type `VegaLite.VLSpec`, which you may interact with using the API described in the [VegaLite.jl](https://github.com/fredo-dedup/VegaLite.jl) documentation. For example, [VegaLite.jl](https://github.com/fredo-dedup/VegaLite.jl) plots can be saved as [PNG](https://en.wikipedia.org/wiki/Portable_Network_Graphics), [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics), [PDF](https://en.wikipedia.org/wiki/PDF) and [EPS](https://en.wikipedia.org/wiki/Encapsulated_PostScript) files. You may save a plot using the `save` function. Note that saving an interactive plot in a non-interactive file format, such as .pdf or .svg will result in a warning `WARN Can not resolve event source: window`, but the plot will be saved as a static image. If you wish to preserve interactive capabilities, you may save it using the .vegalite file extension. If you then open this file in Jupyter lab, the interactive aspects will be preserved. +Alternatively, in order to view just one parameter or variable, call the (unexported) function `Mimi.plot` as below to return a plot object and automatically display the plot in a viewer, assuming `plot` is the last command executed. The function is unexported to avoid namespace conflicts, but can be explicitly imported by users if desired. This call will return the type `VegaLite.VLSpec`, which you may interact with using the API described in the [VegaLite.jl](https://github.com/fredo-dedup/VegaLite.jl) documentation. For example, [VegaLite.jl](https://github.com/fredo-dedup/VegaLite.jl) plots can be saved as [PNG](https://en.wikipedia.org/wiki/Portable_Network_Graphics), [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics), [PDF](https://en.wikipedia.org/wiki/PDF) and [EPS](https://en.wikipedia.org/wiki/Encapsulated_PostScript) files. You may save a plot using the `save` function. Note that saving an interactive plot in a non-interactive file format, such as .pdf or .svg will result in a warning `WARN Can not resolve event source: window`, but the plot will be saved as a static image. If you wish to preserve interactive capabilities, you may save it using the .vegalite file extension. If you then open this file in Jupyter lab, the interactive aspects will be preserved. ```julia using VegaLite run(mymodel) -p = explore(mymodel, component1, parameter1) +p = Mimi.plot(mymodel, component1, parameter1) save("figure.svg", p) ``` diff --git a/src/explorer/explore.jl b/src/explorer/explore.jl index 880602e04..48199d7f2 100644 --- a/src/explorer/explore.jl +++ b/src/explorer/explore.jl @@ -52,11 +52,11 @@ function explore(m::Model; title = "Electron") end """ - explore(m::Model, comp_name::Symbol, datum_name::Symbol) + plot(m::Model, comp_name::Symbol, datum_name::Symbol) Plot a specific `datum_name` (a `variable` or `parameter`) of Model `m`. """ -function explore(m::Model, comp_name::Symbol, datum_name::Symbol) +function plot(m::Model, comp_name::Symbol, datum_name::Symbol) if m.mi === nothing error("A model must be run before it can be plotted") diff --git a/test/test_explorer.jl b/test/test_explorer.jl index 462123cb0..6a84161c5 100644 --- a/test/test_explorer.jl +++ b/test/test_explorer.jl @@ -64,10 +64,10 @@ s = menu_item_list(m) w = explore(m, title = "Testing Window") @test typeof(w) == Electron.Window -#5. explore(m::Model, comp_name::Symbol, datum_name::Symbol; +#5. Mim.plot(m::Model, comp_name::Symbol, datum_name::Symbol; # dim_name::Union{Nothing, Symbol} = nothing) -p = explore(m, :MyComp, :a) +p = Mimi.plot(m, :MyComp, :a) @test typeof(p) == VegaLite.VLSpec{:plot} #6. errors and warnings