Skip to content

group by plot fails when dataframe is accessed by column number #485

Open
@kafisatz

Description

@kafisatz

Describe the bug
For the first plot below, the wrong data is plotted for the second group of data.

Accessing the column by name does not help either df[!,somecolumnname yields identical results as df[!,1] for me.

using PlotlyBase
import PlotlyJS
using DataFrames 

df = DataFrame(a=1:4,b=["a","a","b","b"],timeaxis=[1,2,1,2])

#does not work
#data for both lines **coincides** - why?
plt0 = scatter(df, group=:b, y=df[!,1], x=:timeaxis, mode="lines+markers") 
PlotlyJS.plot(plt0, PlotlyBase.Layout(;title=""))

#works
plt0 = scatter(df, group=:b, y=:a, x=:timeaxis, mode="lines+markers")
PlotlyJS.plot(plt0, PlotlyBase.Layout(;title=""))
julia> versioninfo()
Julia Version 1.10.4
Commit 48d4fd4843 (2024-06-04 10:41 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 32 × AMD Ryzen 9 5950X 16-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, znver3)
Threads: 16 default, 0 interactive, 8 GC (on 32 virtual cores)
Environment:
  JULIA_EDITOR = "code"
  JULIA_NUM_THREADS = 16

julia> using Pkg; pkg"status"
Status `C:\Users\bernhard.konig\.julia\environments\v1.10\Project.toml`
  [6e4b80f9] BenchmarkTools v1.5.0
  [14b8a8f1] PkgTemplates v0.7.51
  [295af30f] Revise v3.5.15

julia>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions