-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add plot configuration class and time profile plots #871
Conversation
> “I became insane, with long intervals of horrible sanity.” - Edgar Allan Poe
this makes ospPlotConfig more general purpose class
This comment was marked as outdated.
This comment was marked as outdated.
I wonder how this (still incomplete) picture would look like in black-white? 😄 But in fact I asked myself already 20 years ago: why would somebody print papers/reports in BW? |
I know this is a rhetorical question, but here you go nonetheless 😅 |
@StephanSchaller Good catch. Yes, this is easy to resolve; I will take care of it. |
Nice. As a color-blind person I cannot even handle the coloured version of it, so the BW-version - well... 😄 |
That would be interested to see if this is the case. I would have implicitly said otherwise, without any data to back my claim. That being said, the fact that some people may still print their report, and when they do, print in BW, should have no bearing on how we create our default plots. At any rate, it should be very easy to create a plot that do not overload grouping criteria such as line types + colors, when this is logically not required |
Yes, as I understand it now, everyone will be able to set their preferences so that everyone will be happy :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes to the documentation are required.
Also some code refactoring resp. questions.
R/default-plot-configuration.R
Outdated
#' R6 class defining the configuration for `{ospsuite}` plots. It holds values | ||
#' for all relevant plot properties. | ||
#' | ||
#' Note that the values this objects contains are of general-purpose utility. In |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this, it is confusing as it sounds as these values can be directly used in e.g. "plot()" function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
R/default-plot-configuration.R
Outdated
#' - font face: `tlf::FontFaces` | ||
#' - linetype: `tlf::Linetypes` | ||
#' | ||
#' The available units for `x`-and `y`-axes variables depend on the dimensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Variables" - don't understand in this context.
"Available units for x and y axes depend on the dimensions of data sets to be plotted".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed accordingly.
R/plot-population-time-profile.R
Outdated
# plot ----------------------------- | ||
|
||
# Which dataset types are present? | ||
datasetTypePresent <- .extractPresentDatasetTypes(dataCombined) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From here on, same comments as for the "individual" function.
Lots of code duplication, I think most of it can be packed in an internal function. Actually only few lines of code differ.
R/utilities-plotting.R
Outdated
dataTypeUnique <- unique(dataCombined$groupMap$dataType) | ||
|
||
if (length(dataTypeUnique) == 2L && all(dataTypeUnique %in% c("observed", "simulated"))) { | ||
datasetTypePresent <- .presentDataTypes$Both |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return early
R/utilities-plotting.R
Outdated
if (length(dataTypeUnique) == 2L && all(dataTypeUnique %in% c("observed", "simulated"))) { | ||
datasetTypePresent <- .presentDataTypes$Both | ||
} else if (length(dataTypeUnique) == 1L && dataTypeUnique == "observed") { | ||
datasetTypePresent <- .presentDataTypes$Observed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return
R/utilities-plotting.R
Outdated
datasetTypePresent <- .presentDataTypes$Both | ||
} else if (length(dataTypeUnique) == 1L && dataTypeUnique == "observed") { | ||
datasetTypePresent <- .presentDataTypes$Observed | ||
} else if (length(dataTypeUnique) == 1L && dataTypeUnique == "simulated") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last else if not required if you return early.
R/default-plot-configuration.R
Outdated
#' @field pointsColor,pointsShape,pointsSize,pointsAlpha A selection key or values for choice of color, fill, shape, size, linetype, alpha, respectively, for points. | ||
#' @field ribbonsFill,ribbonsSize,ribbonsLinetype,ribbonsAlpha A selection key or values for choice of color, fill, shape, size, linetype, alpha, respectively, for ribbons. | ||
#' @field errorbarsSize,errorbarsLinetype,errorbarsAlpha A selection key or values for choice of color, fill, shape, size, linetype, alpha, respectively, for errorbars. | ||
#' @field plotSaveFileName,plotSaveFileFormat,plotSaveFileWidth,plotSaveFileHeight,plotSaveFileDimensionUnits,plotSaveFileDpi File name (without extension) format to which the plot needs to be saved, and the specifications for saving the plot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also - how to change between output to a file and ouput to standard device (e.g. "plot" tab in RStudio)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is now mentioned in the new Saving plot
section.
I also wonder - why is it that slow? Creating a simple individual time profile takes like two seconds, the same plot in esqlabsR is generated almost instantaneously. Is it ggplot, or TLF, or..? |
Last refactoring:
Create one internal function. There are only two sections that differ between individual and population, and they are identified by checking whether
The exposed functions just forward to the internal:
|
Co-Authored-By: Pavel Balazki <[email protected]>
Great idea! Done. |
I did not have time to review the code at all. I will comment on this later today or tomorrow |
Sorry, this has been handing here for so long that I thought you already looked into it. |
This PR is coming from a branch that doesn't have issue number because it was supposed to be short-lived and was off shoot from #858, but it has now become the primary branch and #858 has been closed in favour of the current one.
TODO:
(removed after team discussion, which deemed it unnecessary)createPlotConfiguration()
DefaultPlotConfiguration
rename to something other thanospPlotConfiguration
DefaultPlotConfiguration
(CreateDefaultPlotConfiguration
class #877)plotIndividualTimeProfile()
)plotPopulationTimeProfile()
)plotIndividualTimeProfile()
plotPopulationTimeProfile()
add examples to manual(DocumentingDataCombined
#756)NEWS.md
Part of #674
Related to #815
Related to #832
Related to #833
Closes #877
Closes #878
Closes #920