Skip to content

Conversation

mwaskom
Copy link
Owner

@mwaskom mwaskom commented Mar 11, 2023

This PR continues the work in #2429, addressing boxplot. As in the related PRs, boxplot now runs through the common variable assignment and axes setup and has gained the new native_scale and formatter parameters. I won't repeat all the details here.

The PR also adds a number of new features:

Unfilled boxes

With fill=False, no box patch will be drawn and colors will be mapped to the line elements:

ax = sns.boxplot(tips, x="day", hue="day", y="total_bill", fill=False)

Gapped dodging

With gap > 0, boxes will be shrunk along the orient axes after dodging, leaving a gap between them:

sns.boxplot(tips, x="day", y="total_bill", hue="sex", gap=.1)

Closes #1455

Single-argument linecolor parameterization

The new linecolor parameter allows to color of all line elements in the boxplot to be changed in one step

sns.boxplot(tips, x="size", y="total_bill", color="w", linecolor="r")

Artist containerization

The artists that comprise each boxplot are now packaged in a BoxPlotContainer for easier post-plotting access

ax = sns.boxplot(flights_wide, fill=False, showcaps=False)
bxp = ax.containers[0]
bxp[5].box.set_color("g")
plt.setp(bxp[6], color=".2")
plt.setp(bxp[7].whiskers, color="r")

Increased customizability with matplotlib prop dicts

Any customizations passed through matplotlib keyword arguments are now applied on top of the changes that seaborn makes to apply its boxplot style.

Default flier marker

The default flier marker now follows the matplotlib rcparams so that it can be globally customized.

Other issues

The improvements to variable assignment fix #2756.

@codecov
Copy link

codecov bot commented Mar 11, 2023

Codecov Report

Merging #3294 (e10392d) into master (e1e36cb) will decrease coverage by 0.04%.
The diff coverage is 97.13%.

❗ Current head e10392d differs from pull request most recent head 3786b8f. Consider uploading reports for the commit 3786b8f to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3294      +/-   ##
==========================================
- Coverage   98.38%   98.35%   -0.04%     
==========================================
  Files          77       77              
  Lines       24712    24942     +230     
==========================================
+ Hits        24313    24531     +218     
- Misses        399      411      +12     
Impacted Files Coverage Δ
seaborn/categorical.py 97.51% <95.54%> (-0.33%) ⬇️
tests/test_categorical.py 99.55% <98.09%> (-0.19%) ⬇️

@mwaskom mwaskom merged commit 7231fc2 into master Mar 14, 2023
@mwaskom mwaskom deleted the cat/box_refactor branch March 14, 2023 23:54
@mwaskom mwaskom mentioned this pull request May 4, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

boxplot crashes when data is a Series that doesn't contain an index 0 [Boxplot] Gap Inside Grouped Boxes

1 participant