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

Updates boxplot to allow for custom percentiles #440

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MattAmos
Copy link

@MattAmos MattAmos commented Apr 21, 2021

Adds the ability for custom percentiles to be passed to boxplots (and grouped box plots). Retains current default behaviour of using quartiles when custom percentiles are omitted.

using Plots
using StatsPlots
using RDatasets

school = RDatasets.dataset("mlmRev", "Hsb82")

Default quartiles

@df school groupedboxplot(string.(:Sector), :MAch, group=string.(:Sx))

image

@df school groupedboxplot(string.(:Sector), :MAch, notch=true, group=string.(:Sx))

image

Custom Percentiles

@df school groupedboxplot(string.(:Sector), :MAch, group=string.(:Sx), percentiles=[0.05, 0.25, 0.50, 0.75, 0.95])

image

@df school groupedboxplot(string.(:Sector), :MAch, group=string.(:Sx), notch=true, percentiles=[0.05, 0.25, 0.50, 0.75, 0.95])

image

@df school groupedboxplot(string.(:Sector), :MAch, group=string.(:Sx), percentiles=[0.05, 0.50, 0.95])

image

@df school groupedboxplot(string.(:Sector), :MAch, group=string.(:Sx), notch=true, percentiles=[0.05, 0.50, 0.95])

image

@MattAmos
Copy link
Author

Any feedback on this would be greatly appreciated.

@BeastyBlacksmith
Copy link
Member

Can you add some tests? Otherwise looks good to me

@cristobaltapia
Copy link

@MattAmos thanks for this PR. I was wondering if it would be possible to also consider the placement of the whiskers as percentiles. As I understand this PR, it only allows to modify the extent of the box and add additional lines within it at the specified positions. Could we add an option like whiskerpercentile=[0.05, 0.95] that modifies the extension of the whiskers (currently controlled exclusively by IQR * range)?

@MattAmos
Copy link
Author

Thanks @BeastyBlacksmith and @cristobaltapia. I'll work on adding tests and configurable whiskers.

@Ph0non
Copy link

Ph0non commented Jan 11, 2024

Any updates on this?

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

Successfully merging this pull request may close these issues.

4 participants