需要在Julia中创建饼图仪表盘。

5

我需要为每个工作类别设计一个饼图表。我的数据看起来像这样

 BR PROG_JOB1 PROG_JOB2 PROG_JOB3
0 BR1 0.5 0.4 0.5
1 BR2 0.3 0.2 0.6
2 BR3 0.6 0.5 0.3

我需要为每个JOB进度创建一个圆形仪表盘。在Julia中应该如何实现?

我尝试过使用Plots.jl中的proj=:polar,参考https://lumiamitie.github.io/r/pie-gauge-in-ggplot2/,但并没有解决问题。

期望输出enter image description here


你链接了一个 R 库,所以当然选项不适用于 Julia。据我所知,Python 或 Julia 没有现成的方法来实现这一点。 - jling
@GoFORIT 你是如何生成你的输出的? - giantmoa
手动在Microsoft Excel中进行! - GoFORIT
2个回答

5
使用 StatisticalGraphics 软件包:
using InMemoryDatasets
using StatisticalGraphics
ds=Dataset(BR=["BR1","BR2","BR3"],JOB1=[.5,.3,.6],JOB2=[.4,.2,.5],JOB3=[.5,.6,.3])

# data manipulation
ds2=transpose(gatherby(ds,:BR),r"JOB")
modify!(ds2,:_c1=>byrow(x->[x,1-x])=>:progress,:BR=>byrow(x->[x,missing])=>:cat)
flatten!(ds2,[:progress,:cat])

# plot
sgplot(
      groupby(ds2,:_variables_),
      Pie(category=:cat,response=:progress,group=:BR,innerradius=0.3, label=:percent,labelcolor=:white,colormodel=[:blue,:white,:orange,:green]),
      layout=:row,headercolname=false,legend=false,width=200,height=200
      )

plot


非常感谢。我如何将BR1、BR2、BR3添加到每个进度条中? - GoFORIT
1
也许可以添加另一个饼图仅用于标签,将 Pie(...) 更改为 [Pie(category=:cat, response=:progress, group=:BR, innerradius=0.3, label=:percent, labelcolor=:white, colormodel=[:blue,:white,:orange,:green]), Pie(category=:cat,group=:BR,label=:category,colormodel=[:white], innerradius=0.3,endangle=-0.0001, labelalign=:right)] - giantmoa

0

你可以使用GLMakie手动绘制它:

using GLMakie
pie([0.5, 0.5], color=[:green, :white], inner_radius=0.8, strokecolor=:white)
pie!([0.3, 0.7], color=[:orange, :white], inner_radius=0.6, radius=0.79, strokecolor=:white)
pie!([0.6, 0.4], color=[:blue, :white], inner_radius=0.4, radius=0.59, strokecolor=:white)

makie_output


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接