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

Grouped ecdfplot(..., group=) plot emits different result from multiple ecdfplot(...)s for each group #460

Open
tai opened this issue Jul 29, 2021 · 1 comment

Comments

@tai
Copy link

tai commented Jul 29, 2021

I noticed StatsPlots.ecdfplot() emits unexpected plot when I use a group= parameter.

When I use 2 ecdfplot() calls to compare 2 groups, I get this:

df = DataFrame(v=1:100, ab=vcat(repeat(["A"], 50), repeat(["B"], 50)));
ecdfplot(df[df.ab .== "A", :v], label="A")
ecdfplot!(df[df.ab .== "B", :v], label="B")

image

These CDF plots are correct as group "A" has 1:50 and "B" has 51:100.

However, once I switch to a single ecdfplot(..., group=) call with a group= parameter, I get this for the same dataframe:

# Also,
# @df df ecdfplot(:v, group=:ab)
# emits the same plot
ecdfplot(df.v, group=df.ab)

image

This plot doesn't look right as what is expected is an independent CDF plot for each group, just like the former result.

I was struggling to figure out why I'm getting so similar CDF plots for 2 groups (with real data) I'm comparing, and ended up with above examples.

Following is the setup I'm on:

Julia Version 1.5.3
Commit 788b2c77c1 (2020-11-09 13:37 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2698 v4 @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, broadwell)

[91a5bcdd] Plots v1.19.4
[f3b207a7] StatsPlots v0.14.26
@sethaxen
Copy link
Member

Yes this occurs because of how ecdfplot is currently implemented as a user plot. When #453 is finished, it should fix this.

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

No branches or pull requests

2 participants