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

plotIndividualTimeProfile - multiple observed data within one group should get different symbols #980

Closed
PavelBal opened this issue May 24, 2022 · 12 comments · Fixed by #1054

Comments

@PavelBal
Copy link
Member

RIF 20mg qd 14d_DC

Panel B - there are two observed data sets, both having the same symbols. They should have different symbols.

In the legend, only one entry should be shown, using the symbol of the first observed data (so basically the legend should not change).

@IndrajeetPatil
Copy link
Member

Minimal reproducible example:

library(ospsuite)
#> Loading required package: rClr
#> Loading the dynamic library for Microsoft .NET runtime...
#> Loaded Common Language Runtime version 4.0.30319.42000

dataSet1 <- DataSet$new(name = "Dataset1")
dataSet1$setValues(1, 1)
dataSet1$yDimension <- ospDimensions$`Concentration (molar)`
dataSet1$molWeight <- 1

dataSet2 <- DataSet$new(name = "Dataset2")
dataSet2$setValues(2, 2)
dataSet2$yDimension <- ospDimensions$`Concentration (mass)`
dataSet2$molWeight <- 1

dataSet3 <- DataSet$new(name = "Dataset3")
dataSet3$setValues(1, 3)
dataSet3$yDimension <- ospDimensions$`Concentration (mass)`
dataSet3$molWeight <- 1

myCombDat <- DataCombined$new()
myCombDat$addDataSets(
  c(dataSet1, dataSet2, dataSet3),
  groups = c("myGroup", "myGroup", "myGroup")
)

plotIndividualTimeProfile(myCombDat)
#> Warning: Removed 3 rows containing missing values (geom_segment).
#> Removed 3 rows containing missing values (geom_segment).

Created on 2022-05-25 by the reprex package (v2.0.1.9000)

@IndrajeetPatil
Copy link
Member

@pchelle can correct me if I am mistaken about this, but AFAIK this is currently not possible with tlf.

The color, shape, linetype, etc. are all currently mapped to group. That is, each group will get its own color, shape, linetype, etc. But there is no way to further specify any mapping within each group, which is what needs to happen here.

I am not sure, but maybe adding shape to time-profile data mappings might make it possible? Currently, it doesn't support that:

TimeProfileDataMapping$new(
  x = NULL,
  y = NULL,
  ymin = NULL,
  ymax = NULL,
  group = NULL,
  color = NULL,
  fill = NULL,
  linetype = NULL
)

If it is supported, maybe we can do something like the following to support the current FR:

TimeProfileDataMapping$new(
  color = "group", # each group gets its own color
  shape = "name", # each datasets gets its own shape
  linetype = "group"
)

@IndrajeetPatil
Copy link
Member

@PavelBal Can you confirm that the legend for the plot should look something like this?

The way ggplot2 is designed, all aesthetic mappings are shown in the legend.

image

@PavelBal
Copy link
Member Author

PavelBal commented Jun 8, 2022

No, in this case, only three legend entries should be present, one per grouping. The presented symbol should be the first symbol used in the grouping.

@IndrajeetPatil
Copy link
Member

Is that not confusing?

How are the readers supposed to know which shape corresponds to which observed dataset if you show only one shape in the legend per group?

@PavelBal
Copy link
Member Author

PavelBal commented Jun 8, 2022

Best solution would be to have an option to either create a separate entry for each data set in a grouping or only one for a grouping. If it is not possible - then stick to one entry per grouping.

@IndrajeetPatil
Copy link
Member

IINM, the latter plot is what you have in mind, right? That is, use two separate visual encodings but only show one in the legend?

library(tidyverse)

df <- dplyr::tibble(
  xValues = rep(c(0, 1, 2, 3, 4), 4),
  yValues = sample.int(20, 20), 
  group = c(rep("myGroup1", 10), rep("myGroup2", 10)), 
  name = c(rep("data1", 5),  rep("data2", 5), rep("data3", 5),  rep("data4", 5))
)

ggplot(df, aes(xValues, yValues, color = group, shape = name)) + 
  geom_point(size = 3)

ggplot(df, aes(xValues, yValues, color = group, shape = name)) + 
  geom_point(size = 3) +
  guides(shape = "none")

Created on 2022-07-22 by the reprex package (v2.0.1.9000)

@PavelBal
Copy link
Member Author

Yes.

@IndrajeetPatil
Copy link
Member

But isn't that confusing?

Looking at this plot, the legend gives you no clue as to what the shapes are representing, or which shape represents which dataset.

image

@PavelBal
Copy link
Member Author

Sometimes it is not necessary to see the exact names of the data sets but just to see wich points belong to a data set (e.g., data from 10 individuals... we don't want to see 10 entries in the legend, it is sufficient to see which points belong to the same individual).

If the user wants to see directly which points belong to which data set, he can just assign them to a separate groups ;)

@IndrajeetPatil
Copy link
Member

Got it!

cc @pchelle

@IndrajeetPatil
Copy link
Member

With #1054

library(ospsuite)
#> Loading required package: rClr
#> Loading the dynamic library for Microsoft .NET runtime...
#> Loaded Common Language Runtime version 4.0.30319.42000

dataSet1 <- DataSet$new(name = "Dataset1")
dataSet1$setValues(1, 1)
dataSet1$yDimension <- ospDimensions$`Concentration (molar)`
dataSet1$molWeight <- 1

dataSet2 <- DataSet$new(name = "Dataset2")
dataSet2$setValues(2, 1)
dataSet2$yDimension <- ospDimensions$`Concentration (mass)`
dataSet2$molWeight <- 1

dataSet3 <- DataSet$new(name = "Dataset3")
dataSet3$setValues(1, 3)
dataSet3$yDimension <- ospDimensions$`Concentration (mass)`
dataSet3$molWeight <- 1

myCombDat <- DataCombined$new()
myCombDat$addDataSets(
  c(dataSet1, dataSet2, dataSet3),
  groups = "myGroup"
)

plotIndividualTimeProfile(myCombDat)
#> Warning: Removed 3 rows containing missing values (geom_segment).
#> Removed 3 rows containing missing values (geom_segment).

Created on 2022-07-29 by the reprex package (v2.0.1.9000)

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