JuliaPhysics / Measurements.jl

Error propagation calculator and library for physical measurements. It supports real and complex numbers with uncertainty, arbitrary precision calculations, operations with arrays, and numerical integration.

Home Page:https://juliaphysics.github.io/Measurements.jl/stable/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bad integration with Plots' boxplot

bertulli opened this issue · comments

Hi all!
First, thanks for your work. I have a large DataFrame, which I have already combined, enriched, grouped eccetera. Right now, it presents like this:

julia> df_grouped = groupby(df_temp, :mnemonic)
GroupedDataFrame with 36 groups based on key: mnemonic
First Group (106 rows): mnemonic = "adc"
 Row │ Instruction    Base power (W)     mnemonic 
     │ Any            Quantity…          String   
─────┼────────────────────────────────────────────
   1 │ adc_r0_r2_0    0.082735±6.4e-5 W  adc
   2 │ adc_r0_r2_10   0.082995±6.5e-5 W  adc
   3 │ adc_r0_r2_100  0.083458±6.4e-5 W  adc
   4 │ adc_r0_r2_105  0.083524±6.4e-5 W  adc
   5 │ adc_r0_r2_110  0.083737±6.5e-5 W  adc
  ⋮  │       ⋮                ⋮             ⋮
 102 │ adc_r0_r0_75   0.086597±6.1e-5 W  adc
 103 │ adc_r0_r0_80    0.08513±6.0e-5 W  adc
 104 │ adc_r0_r0_85    0.08737±6.2e-5 W  adc
 105 │ adc_r0_r0_90   0.086447±6.2e-5 W  adc
 106 │ adc_r0_r0_95   0.086695±6.0e-5 W  adc
                                   96 rows omitted
⋮
Last Group (106 rows): mnemonic = "sbcs"
 Row │ Instruction     Base power (W)     mnemonic 
     │ Any             Quantity…          String   
─────┼─────────────────────────────────────────────
   1 │ sbcs_r0_r2_0    0.083804±6.3e-5 W  sbcs
   2 │ sbcs_r0_r2_10   0.084062±6.2e-5 W  sbcs
   3 │ sbcs_r0_r2_100  0.084497±6.5e-5 W  sbcs
   4 │ sbcs_r0_r2_105  0.084568±6.5e-5 W  sbcs
   5 │ sbcs_r0_r2_110  0.084778±6.4e-5 W  sbcs
  ⋮  │       ⋮                 ⋮             ⋮
 102 │ sbcs_r0_r0_75   0.088057±6.7e-5 W  sbcs
 103 │ sbcs_r0_r0_80   0.086408±6.4e-5 W  sbcs
 104 │ sbcs_r0_r0_85   0.088377±6.6e-5 W  sbcs
 105 │ sbcs_r0_r0_90   0.088026±6.7e-5 W  sbcs
 106 │ sbcs_r0_r0_95   0.088148±6.6e-5 W  sbcs
                                    96 rows omitted

Now I want to show each instruction (corresponding to a group) as a box plot:

p = boxplot(0)
for df_group in df_grouped
    boxplot!(df_group[:, measure_power_sym], label=df_group[1,:mnemonic])
end
gui(p)

However, this causes some mess:
mess
If I try to show only the first group (for debugging purpose), with a minor code modification

p = boxplot(0)
for df_group in df_grouped[1:1]
    boxplot!(df_group[:, measure_power_sym], label=df_group[1,:mnemonic])
end
gui(p)

I get
mess
Is this normal? How can I make a single boxplot?


Note that if I don't use Measurements.jl, but only use the mean, I get "expected" results:
mess
mess
Thanks!

Yeah, if you don't want Measurements automatic plotting, you should get the values of your data when you plot it, I don't think there are many other alternatives. I don't see Measurements in your snippets, BTW.

Indeed it works using Measurements.value. However I wonder: since using boxplot this is not the behavior one usually would want, would it make sense to override Plots.boxplot? (Correct me if I am wrong, but box plots are not meant to show error bars, do they?)