2

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?

1 Answer 1

1

You should use pointpos=0:

julia> using PlotlyJS, RDatasets, DataFrames

julia> df = RDatasets.dataset("datasets", "iris")[!, 1:4];

julia> PlotlyJS.plot(df, x=:PetalLength, y=:SepalWidth, boxpoints="all", kind="box", pointpos=0)

enter image description here


I would like to add the answer to the provided dataset in the question to show the expected result (@Shayan of course found the answer!):

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

Output:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.