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] Colors are not assigned to pie chart properly #3214

Closed
bvilmann opened this issue Jan 7, 2021 · 1 comment · Fixed by #4208
Closed

[BUG] Colors are not assigned to pie chart properly #3214

bvilmann opened this issue Jan 7, 2021 · 1 comment · Fixed by #4208
Labels

Comments

@bvilmann
Copy link

bvilmann commented Jan 7, 2021

Details

Colors are not assigned to pie chart properly.

This:

pie(rand(3),
    color=[:blue :green :red]
    )

Plots this:
grafik

Regarding a closed issue, I am using the correct syntax for assigning colors.

Taken into account that I am new to Julia and Plots, I looked in the source and found that the recipe does not handle any input colors:

@recipe function f(::Type{Val{:pie}}, x, y, z)
    framestyle --> :none
    aspect_ratio --> true
    s = sum(y)
    θ = 0
    for i in eachindex(y)
        θ_new = θ + 2π * y[i] / s
        coords = [(0.0, 0.0); partialcircle(θ, θ_new, 50)]
        @series begin
            seriestype := :shape
            label --> string(x[i])
            x := first.(coords)
            y := last.(coords)
        end
        θ = θ_new
    end
end
@deps pie shape

Is this part of the problem or lies this elsewhere?

I would happily implement changes but I need some supervision for this.

Backends

This bug occurs on ( insert x below )

Backend yes no untested
gr (default) x
pyplot x
plotly x
plotlyjs x
pgfplotsx x
inspectdr x

Versions

Plots.jl version: 1.10
Backend version (]st -m):
Output of versioninfo():

Julia Version 1.5.2
Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
  JULIA = C:\Users\Benjamin\AppData\Local\Programs\Julia 1.5.2
  JULIA_EDITOR = "C:\Users\Benjamin\AppData\Local\atom\app-1.53.0\atom.exe"  -a
  JULIA_NUM_THREADS = 2
@bvilmann bvilmann added the bug label Jan 7, 2021
@bvilmann bvilmann changed the title [BUG] [BUG] Colors are not assigned to pie chart properly Jan 7, 2021
@nick4f42
Copy link
Contributor

It should now work with a vector of colors like [:red, :green, :blue].

Passing a row vector [:red :green :blue] still makes the pie entirely red but I think that's expected since each column corresponds to a series and a pie plot is only one series.

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