5

I got the following graph for each job title with salary in box plot: enter image description here

enter image description here

so there are some outliers here, presented as dot, I want to make some jitters like this for each job title have outliers:

enter image description here

Is there any way I can do it with Vegalite package?
can someone gives me some advices please?
Thanks in advance!

hahaha
  • 183
  • 5
  • If I'm correct, your desired output is from `StatisticalGraphics.jl` package. In that case,use that package to create your box plot and then use its `vegalite` spec and push it back to `VegaLite.jl`. – giantmoa Nov 15 '22 at 23:06
  • yes its from StatisticalGraphics.jl package! I am relatively new to julia, can you please be more specific about it? I understand creation of box plot but what does use vegalite spec and push it back to vegalit.jl means? Thanks in advance!! – hahaha Nov 16 '22 at 12:11
  • 1
    added an answer – giantmoa Nov 16 '22 at 23:09

2 Answers2

2

using StatisticalGraphics.jl package:

using InMemoryDatasets
using StatisticalGraphics
ds=Dataset(x=[1,2],y=[2,3])
sgplot(ds,Line(x=:x,y=:y))

if you run this code you'll see enter image description here press "view source" to see VegaLite specs.

giantmoa
  • 327
  • 5
1

You can read a solution for jittering here:

https://github.com/vega/vega-lite/issues/4703

Davide Bacci
  • 16,647
  • 3
  • 10
  • 36
  • Hi, thanks for the reply! I have tried that, with code: new |> @vlplot(mark={:point},transform=[{calculate="random()", as="random"}],x=:job_title,y=:salary_in_usd,yoffset={field="random",type="quantitative"},width=800,height=400), but this is point graph, I want to have box plot but only jitters to the outliers(like the last graph), do you have any ideas how to achieve that? Thanks! – hahaha Nov 15 '22 at 13:47
  • 2
    I haven't done it before but if you can provide a working Vega spec in the Vega editor along with data, I could try and take a look. – Davide Bacci Nov 15 '22 at 14:07
  • Goodevening, here's my code for processing data: import Downloads using DLMReader, VegaLite, InMemoryDatasets data=Downloads.download("https://raw.githubusercontent.com/akshdfyehd/salary/main/ds_salaries.csv") ds=filereader(data,emptycolname=true) new=filter(ds,:employment_type,by= ==("FT")) select!(new,:job_title,:salary_in_usd) – hahaha Nov 16 '22 at 12:17