JuliaPlots / PlotlyJS.jl

Julia library for plotting with plotly.js
Other
413 stars 77 forks source link

[Question] Plotting points over box plot in PlotlyJS Julia #458

Closed shayandavoodii closed 1 year ago

shayandavoodii commented 1 year ago

This is a cross-post.
I would like to plot data points over a box plot in PlotlyJS in Julia. Here is some reproducible code to create a box plot with data points side by side:

using PlotlyJS, CSV, DataFrames
df = dataset(DataFrame, "tips")
PlotlyJS.plot(df, x=:time, y=:total_bill, boxpoints="all", kind="box")

Output:

enter image description here

As you can see it nicely plots the data points and box plot side by side, but I would like to add the point on top of the box plot. In plotly python we may use stripmode = "overlay", but this doesn't work for PlotlyJS. So I was wondering if anyone knows how to add the points on top of the box plot?

empet commented 1 year ago

Just insert pointpos=0 in the last line:

PlotlyJS.plot(df, x=:time, y=:total_bill, boxpoints="all", kind="box")

and the points are plotted over boxes. There is no stripmode attribute for PlotlyJS.box or the python version go.Box. Perhaps you saw somewhere a figure defined by the Plotly Express function px.strip, which can be called with stripmode="overlay" or stripmode="group".

shayandavoodii commented 1 year ago

Thank you so much. I got it!