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

Consider adding annotations for UCL, LCL and mean #141

Closed
mauriziopassariello opened this issue Jan 26, 2022 · 8 comments
Closed

Consider adding annotations for UCL, LCL and mean #141

mauriziopassariello opened this issue Jan 26, 2022 · 8 comments
Labels
enhancement New feature or request
Milestone

Comments

@mauriziopassariello
Copy link

Maybe this is a feature that already exists and I don't know(if so apologies!)...it would be useful to have the control limits and the mean displayed on the chart next/above the lines.

@ThomUK
Copy link
Contributor

ThomUK commented Jan 29, 2022

I think this would be a good idea too, and something I have occasionally needed to make some commentary clear. Turn off and on-able with an argument to ptd_create_ggplot(), perhaps?
Do you fancy putting together a PR?

I think the challenges are handling overplotting with points / plot boundaries, and also creating a clean API to handle labelling when the limits have been re-based (perhaps labelling first and most recent limits only to enable commentary on improvement shown by the chart?).

@mauriziopassariello
Copy link
Author

Hi Tom, adding an argument to turn this feature on/off in ptd_create_ggplot() may be the way to go.
IT skills are limited but happy to test it out if someone comes up with something like this.

@ThomUK
Copy link
Contributor

ThomUK commented Jan 29, 2022

Sounds good - thanks for raising the issue!

@ThomUK ThomUK added this to the 0.2.0 milestone Jun 16, 2022
@ThomUK ThomUK added the enhancement New feature or request label Jun 16, 2022
@francisbarton
Copy link
Contributor

The NHS-R newscast alerted me to this issue :-)
Then I was just reading this presentation (Future NHS link) and noticed that they have used a secondary y-axis to show the limits and mean. Though this would get messy if you tried including these for multiple sets after a rebase, as in Tom's comment 2 above. Though it handles the issue of overplotting well. I don't love it but it's an option.

@ThomUK
Copy link
Contributor

ThomUK commented Jan 19, 2023

It would be nice to avoid a secondary axis if possible.
I was thinking of 4 separate annotations (LCL, Mean, UCL, and target), aligned vertically to their dotted line, and horizontally wherever they cause the fewest problems. Probably on the right so that the most recent (post-rebase) information is covered.

As Tom found with the icons, there is going to be overlapping with some chart combinations, which is hard to avoid without introducing a border for the annotations to sit in.

@tomjemmett
Copy link
Member

the secondary axis way of labelling is a really neat approach and probably the way I would attack this, it's certainly what I've used in the past. In summary (at least, what I did): your secondary axis has the same limits as the primary axis, but different breaks: you set the breaks to be at lcl, mean, ucl, target (rather than a regular interval of +x from last tick). The labels then would use a function from {scales} to neatly format the values.

There are some issues that may arise from this:

  1. this approach only works on the last point of data, so won't tell you the values if you rebase (actually, I would argue this is a feature rather than an issue)
  2. it reduces the plot area, with the icons these are positioned absolutely in a (specified) corner of the plot area. As with point 1, the plot area is reduced so we may have more overlapping of icons with data points
  3. this will likely not work with facets. It requires independent axes (I think we specify axis="free" though?). Same issue again as point 1, plot area is reduced, which is going to be an issue with facets as you are already cramming a lot of information into one space

The alternative is to use something like geom_annotate to add values into the plot area: this I feel is something that users should do themselves, as you will likely require playing about on case by case basis to perfectly position your labels to prevent overlapping. Perhaps a vignette could show this method off, but leave it at that.

@francisbarton
Copy link
Contributor

PR #188 was created to address this issue, and that has now been merged into main.
Do people on this thread want to keep the issue open for further discussion or enhancement of the fix?
In my mind we can close this now, but there are still potential design/aesthetic questions about the whole secondary axis solution, if you want to have them!

@ThomUK
Copy link
Contributor

ThomUK commented Oct 23, 2023

Thanks for the work on the PR Fran! Have seen the proposed docs updates in #192
Similarly any tweaks would be best proposed in a new issue, so closing this one now...
Thank you!

@ThomUK ThomUK closed this as completed Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

4 participants