Quinten
Quinten

Reputation: 41285

Plotting points over box plot in PlotlyJS Julia

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?

Upvotes: 2

Views: 397

Answers (1)

Shayan
Shayan

Reputation: 6295

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

Upvotes: 1

Related Questions