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

[BUG] grouping Measurement data leads to wrong errorbars in plot #4917

Closed
lukas-weber opened this issue Apr 9, 2024 · 2 comments · Fixed by #4967
Closed

[BUG] grouping Measurement data leads to wrong errorbars in plot #4917

lukas-weber opened this issue Apr 9, 2024 · 2 comments · Fixed by #4967
Labels

Comments

@lukas-weber
Copy link
Contributor

Details

using Measurements
using Plots

data = range(0, 1, 10)  range(0, 1, 10)
ids = mod.(1:10, 2)

plot(
   plot(data, title="expected errorbars"),
   plot(data, group=ids, title="wrong errorbars")
)

Quite scary. It seems like in the group version, the ungrouped list of uncertainties is accessed using the intra-group index.

Backends

This bug occurs on ( insert x below )

Backend yes no untested
gr (default) x
pythonplot
plotlyjs
pgfplotsx
unicodeplots x
inspectdr
gaston

Versions

Plots.jl version: v1.40.3
Backend version (]st -m <backend(s)>): GR v0.73.3, UnicodePlots v3.6.4
Output of versioninfo():

Julia Version 1.10.2
Commit bd47eca2c8a (2024-03-01 10:14 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 32 × Intel(R) Xeon(R) Gold 6244 CPU @ 3.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, cascadelake)
Threads: 1 default, 0 interactive, 1 GC (on 32 virtual cores)
@lukas-weber
Copy link
Contributor Author

I did some digging. First I thought the problem was downstream with the Measurements.jl recipe, but I do not know what could be wrong with it.

Instead, looking at how the GroupBy recipe gets applied in Plots.jl, I think the issue is that in this case, it will attach the idxfilter attribute to the series rather than actually filtering the data. Later, there is a call to

# RecipesPipeline/src/group.jl
function filter_data!(plotattributes::AKW, idxfilter)
    for s in (:x, :y, :z)
        plotattributes[s] = filter_data(get(plotattributes, s, nothing), idxfilter)
end

Which will filter the data but not :xerror, :yerror, or :zerror, leading to the result from the minimal example above. I am pretty sure adding them to filter_data! would fix it and would have made a PR, however I noticed you are in the middle of restructuring for Plots v2. Should this go to the v2 branch or master?

@isentropic
Copy link
Member

It should go to.v2 thanks

BeastyBlacksmith added a commit that referenced this issue Oct 2, 2024
* RecipesPipeline: GroupBy: apply idxfilter to errorbars too

Fixes #4917

* modifiy .zenodo.json

---------

Co-authored-by: Simon Christ <SimonChrist@gmx.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants