Q:

How to add markers to a boxplot in pandas

I'd like to add marker to indicate quartile number in box plot, but it seems boxplot() doesn't accept 'marker' keyword. Is there a way to do this using pandas?
I'd also like to add marker to indicate data mean, anyone knows how to add an arbitrary marker to a plot
Thanks

A:

You can select the axis you want to plot the boxplot on and then add your own markers/text. For example:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

df = pd.DataFrame()
df['score'] = np.random.randint(0,100,1000)

fig, ax = plt.subplots(1,1)
df.boxplot(column='score', ax=ax)
q1 = df.quantile(0.25)
q3 = df.quantile(0.75)
ax.scatter(1, q1, c='k', label='Q1')
ax.text(1.1, q1, "Q1 = {0}".format(q1['score']))
ax.scatter(1, q3, c='k', label='Q3')
ax.text(1.1, q3, "Q3 = {0}".format(q3['score']))
fig.show()

