soungalo
soungalo

Reputation: 1338

Plotly - how to make boxplot without boxes?

I am trying to use plotly in python to create box plots, but I just want the points, not the box, whiskers or anything else. Something like this: enter image description here

Couldn't find a way to do that. The best I could do is set boxpoints='all', but that only displays the points besides the boxes: enter image description here

Is this even possible? Any ideas for a workaround?

Upvotes: 5

Views: 6549

Answers (1)

vestland
vestland

Reputation: 61114

Set pointpos = 0 and colors of desired elements to remove to rgba(0,0,0,0)

Plot:

enter image description here

Code for Jupyter Notebook:

# imports
import plotly
from plotly import tools
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import pandas as pd
import numpy as np
import plotly.plotly as py
import plotly.graph_objs as go

# setup
init_notebook_mode(connected=True)
np.random.seed(123)

# data
y0 = np.random.randn(50)-1
y1 = np.random.randn(50)+1

# traces
trace0 = go.Box(
    y=y0, boxpoints = 'all', pointpos = 0,
    marker = dict(color = 'rgb(66, 167, 244)'),
    line = dict(color = 'rgba(0,0,0,0)'),
    fillcolor = 'rgba(0,0,0,0)'
)

trace1 = go.Box(
    y=y1, boxpoints = 'all', pointpos = 0,
    marker = dict(color = 'rgb(84, 173, 39)'),
    line = dict(color = 'rgba(0,0,0,0)'),
    fillcolor = 'rgba(0,0,0,0)'
)

# figure
data = [trace0, trace1]
layout = go.Layout(width=750, height=500)
fig = go.Figure(data, layout)

# plot
iplot(fig)

Upvotes: 6

Related Questions