Douglas Fils
Douglas Fils

Reputation: 311

Panda's boxplot but not showing the box

Is there some way to use boxplots but only show the points?

I have this:

import seaborn as sns
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

data2 = pd.DataFrame(dict(site85_574C=[10,20,30,40, 50], site41_366A=[5,15, 25, 35, 45]),  columns=["site85_574C", "site41_366A"])
data2.boxplot(widths=0.05)
plt.scatter(np.repeat(np.arange(data2.shape[1])+1, data2.shape[0]), data2.values.ravel(), marker='+', alpha=1.0)

but I only want to see the points in the verticle lines, not the box and whiskers

enter image description here

Upvotes: 3

Views: 5865

Answers (1)

K.Chen
K.Chen

Reputation: 1286

data2.boxplot(widths=0.05,  showbox=False, whiskerprops={'lw': 0})

Note, showbox and whiskerprops are the kwds of boxplot, which are in turn passed to matplotlib.boxplot.

Reference

http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.boxplot.html

http://matplotlib.org/api/pyplot_api.html

Upvotes: 2

Related Questions