Skip to content
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 shapes to groups in legend for plotIndividualTimeProfile #439

Open
Felixmil opened this issue Mar 28, 2023 · 3 comments
Open

Add shapes to groups in legend for plotIndividualTimeProfile #439

Felixmil opened this issue Mar 28, 2023 · 3 comments

Comments

@Felixmil
Copy link
Contributor

Originally from Open-Systems-Pharmacology/OSPSuite-R#1206 in OSPSR:

manyObsDC <- readRDS(getTestDataFilePath("manyObsDC"))
manyObsDC$removeGroupAssignment(names = "Vergin 1995.Iv")

dataSet3 <- DataSet$new(name = "Data set 3")
dataSet3$setValues(xValues = 1, yValues = 1, yErrorValues = 1)
dataSet4 <- DataSet$new(name = "Data set 4")
dataSet4$setValues(xValues = 1, yValues = 1, yErrorValues = 1)

manyObsDC$addDataSets(c(dataSet3, dataSet4))

plotIndividualTimeProfile(manyObsDC)

yields:
image

The code responsible for this is in plot-individual-time-profile.R.

  profilePlot <- tlf::plotTimeProfile(
    data = simData,
    dataMapping = simulatedDataMapping,
    observedData = obsData,
    observedDataMapping = observedDataMapping,
    plotConfiguration = timeProfilePlotConfiguration
  )

  # Suppress certain mappings in the legend
  profilePlot <- profilePlot + ggplot2::guides(linetype = "none", shape = "none")

the {tlf} call yields:
image

the tlf output already have "wrong legend symbols" so the changes need to be made inside {tlf}.

@Felixmil Felixmil closed this as not planned Won't fix, can't repro, duplicate, stale Mar 28, 2023
@Felixmil Felixmil changed the title Add shapes to groups in legend Add shapes to groups in legend for plotIndividualTimeProfile Apr 3, 2023
@Felixmil Felixmil reopened this Apr 4, 2023
@Felixmil
Copy link
Contributor Author

Felixmil commented Apr 5, 2023

@pchelle We need help with this. I think the part of the code responsible for that is this:

updateTimeProfileLegend <- function(plotObject, caption) {

More info / examples here: Open-Systems-Pharmacology/OSPSuite-R#1206

@pchelle
Copy link
Collaborator

pchelle commented Apr 6, 2023

The function aimed at

  • providing the appropriate color, fill, shape and linetype values to the ggplot2::scale_ functions
  • display the corresponding legend using ggplot2::guides with option to override aesthetics

One of the issues here is that the scales and legend order are based on factor levels.
Partially shared groupings in the DataMapping can be responsible for the messed up legend.
Also, if the data uses characters, the factor levels use alphabetical order, the function also aimed at re-ordering if users wanted the legend order to be changed.

@pchelle
Copy link
Collaborator

pchelle commented Apr 6, 2023

We may need to rethink this whole function and the caption object so that the mapping can handle all the situations presented in the examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants