这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@mwaskom
Copy link
Owner

@mwaskom mwaskom commented Jul 10, 2022

Similar to how we have Line/Lines, the Bars mark uses a PatchCollection for more efficient drawing. (Unlike with Lines, we don't need to reduce the mappable properties). This can have a substantial effect:

x = np.linspace(-3, 3, 1000)
y = np.exp(-(x ** 2))

%time so.Plot(x, y, color=x).add(so.Bar()).save(io.BytesIO())
%time so.Plot(x, y, color=x).add(so.Bars()).save(io.BytesIO())
CPU times: user 2.66 s, sys: 20.3 ms, total: 2.68 s
Wall time: 1.65 s
CPU times: user 918 ms, sys: 12.3 ms, total: 930 ms
Wall time: 397 ms

The default property values for Bars are also a little different: width is set to 1, edges use the patch.linecolor rc parameter, and edge widths are automatically set using the same approach in histplot to scale down for a dense plot.

so.Plot(diamonds, "price").add(so.Bars(), so.Hist())

image

@codecov
Copy link

codecov bot commented Jul 10, 2022

Codecov Report

Merging #2893 (6415872) into master (3180fd7) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2893      +/-   ##
==========================================
+ Coverage   98.19%   98.20%   +0.01%     
==========================================
  Files          69       69              
  Lines       22435    22561     +126     
==========================================
+ Hits        22030    22156     +126     
  Misses        405      405              
Impacted Files Coverage Δ
seaborn/_marks/bars.py 100.00% <100.00%> (ø)
seaborn/_marks/base.py 98.30% <100.00%> (+0.04%) ⬆️
seaborn/_marks/scatter.py 100.00% <100.00%> (ø)
seaborn/objects.py 100.00% <100.00%> (ø)
tests/_marks/test_bars.py 100.00% <100.00%> (ø)
tests/_marks/test_base.py 100.00% <100.00%> (ø)

@mwaskom mwaskom merged commit 3c8447f into master Jul 11, 2022
@mwaskom mwaskom deleted the bar/speed branch July 11, 2022 00:43
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.

2 participants