Replies: 11 comments 4 replies
-
I don't understand this spec at all. Why don't we just say:
So we could combine any types of plots (Individual time profiles, populatio time profiles, sensitivity plots, Gof plots, ddi ratio plots, custom plots, ...) in any order / layout. |
Beta Was this translation helpful? Give feedback.
-
I was not aware of the More and more I get a feeling I was re-implementing ggplot xD |
Beta Was this translation helpful? Give feedback.
-
OK, how do I create the following plot? I have three sub-plots, and want to arrange them. I also need to add title (SteadyState), and panel numbering (a, b, c) |
Beta Was this translation helpful? Give feedback.
-
library(tlf)
# create a list of plots
ls_plots <- list(
# first plot
plotBoxWhisker(mtcars,
dataMapping = BoxWhiskerDataMapping$new(x = "am", y = "wt"), outliers = FALSE
),
# second plot
plotBoxWhisker(ToothGrowth,
dataMapping = BoxWhiskerDataMapping$new(x = "supp", y = "len")
),
# third plot
plotHistogram(x = mtcars$wt)
)
# create a new instance of plot config class
plotGridObj <- PlotGridConfiguration$new(ls_plots)
plotGridObj$title <- "SteadyState"
plotGridObj$nRows <- 2L
plotGridObj$tagLevels <- "a"
plotGrid(plotGridObj) Created on 2022-05-12 by the reprex package (v2.0.1.9000) |
Beta Was this translation helpful? Give feedback.
-
This does not work with plots created with |
Beta Was this translation helpful? Give feedback.
-
Works just fine for me. Are you sure you are using the development version of tlf with the latest commit? library(ospsuite)
library(ospsuite.utils)
library(tlf)
# import observed data (will return a list of DataSet objects)
dataSet <- loadDataSetsFromExcel(
xlsFilePath = "CompiledDataSet.xlsx",
importerConfiguration = loadDataImporterConfiguration("ImporterConfiguration.xml")
)
# simulation results
sim <- importResultsFromCSV(
simulation = loadSimulation("Stevens_2012_placebo_indiv_results.pkml"),
filePaths = "Stevens_2012_placebo_indiv_results.csv"
)
# create a `DataCombined` object and add observed and simulated data
myDataComb <- DataCombined$new()
myDataComb$addDataSets(dataSet)
myDataComb$addSimulationResults(sim,
quantitiesOrPaths = list(
"Organism|Lumen|Stomach|Metformin|Gastric retention",
"Organism|Lumen|Stomach|Metformin|Gastric retention distal",
"Organism|Lumen|Stomach|Metformin|Gastric retention proximal"
)
)
# set groupings
myDataComb$setGroups(
list(
"Stevens_2012_placebo.Placebo_distal",
"Organism|Lumen|Stomach|Metformin|Gastric retention distal",
"Stevens_2012_placebo.Placebo_proximal",
"Organism|Lumen|Stomach|Metformin|Gastric retention proximal",
"Stevens_2012_placebo.Placebo_total",
"Organism|Lumen|Stomach|Metformin|Gastric retention"
),
list(
# group 1
"Stevens 2012 solid distal",
"Stevens 2012 solid distal",
# group 2
"Stevens 2012 solid proximal",
"Stevens 2012 solid proximal",
# group 3
"Stevens 2012 solid total",
"Stevens 2012 solid total"
)
)
myPC <- DefaultPlotConfiguration$new()
myPC$yUnit <- "%"
p1 <- plotIndividualTimeProfile(myDataComb, myPC)
myPC$linesLinetype <- names(tlf::Linetypes)
p2 <- plotIndividualTimeProfile(myDataComb, myPC)
myPC$linesLinetype <- tlf::Linetypes$dashed
myPC$pointsShape <- "circle"
p3 <- plotIndividualTimeProfile(myDataComb, myPC)
ls_plots <- list(p1, p2, p3)
# create a new instance of plot config class
plotGridObj <- PlotGridConfiguration$new(ls_plots)
plotGridObj$title <- "SteadyState"
plotGridObj$nRows <- 2L
plotGridObj$tagLevels <- "a"
plotGrid(plotGridObj) |
Beta Was this translation helpful? Give feedback.
-
Ok I hate R's lists. How can I dynamically add plot objects to a list?
And it does not work any more. |
Beta Was this translation helpful? Give feedback.
-
Nope,
Actually, |
Beta Was this translation helpful? Give feedback.
-
Just try it with your own example with the plots:
so, no, it does not work. |
Beta Was this translation helpful? Give feedback.
-
This is so ugly. Can we implement a method |
Beta Was this translation helpful? Give feedback.
-
It should be possible to combine multiple plots in one multi-pannel figure:
I was trying to figure out how the API should look like using the currently proposed functional approach (
plotIndividualTimeProfile(dataCombined, plotConfiguration
) and I cannot come up with any idea.Here how it is implemented in
esqlabsR
:Simulated and observed data are grouped in an object of the class
DataMapping
. As opposed toDataCombined
,DataMapping
does not only combines data and defines groupings, but also implements a plotting method and defines some plot properties:Dimension [unit]
)Dimension [unit]
)plotType
- individual profile, population profile, simVsObsSo basically
DataMapping
is a combination ofDataCombined
with a plot configuration. CallingDataMapping$plot()
creates a figure as defined by theplotType
.To create a multipanel figure, multiple
DataMapping
objects are passed to the functionplotMultiPanel
plotMultiPanel(c(dataMapping_timeProfile, dataMapping_simVsObs), plotConfiguration)
In this example,
dataMapping_timeProfile
has theplotType
IndividualProfile, anddataMapping_simVsObs
has theplotType
simulated vs observed.plotConfiguration
is an object that defines the output properties:Will be happy to hear your thoughts on how to implement it in ospsuite-r. @IndrajeetPatil @Yuri05 @msevestre
Beta Was this translation helpful? Give feedback.
All reactions