Für eine genauere Antwort in Bezug auf OP Frage (mit Pandas):
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data = pd.DataFrame({ "A":np.random.normal(0.8,0.2,20),
"B":np.random.normal(0.8,0.1,20),
"C":np.random.normal(0.9,0.1,20)})
data.boxplot()
for i,d in enumerate(data):
y = data[d]
x = np.random.normal(i+1, 0.04, len(y))
plt.plot(x, y, mfc = ["orange","blue","yellow"][i], mec='k', ms=7, marker="o", linestyle="None")
plt.hlines(1,0,4,linestyle="--")
Alte Version (allgemeinere):
Mit Matplotlib:
import numpy as np
import matplotlib.pyplot as plt
a = np.random.normal(0,2,1000)
b = np.random.normal(-2,7,100)
data = [a,b]
plt.boxplot(data) # Or you can use the boxplot from Pandas
for i in [1,2]:
y = data[i-1]
x = np.random.normal(i, 0.02, len(y))
plt.plot(x, y, 'r.', alpha=0.2)
Welche gibt, dass:
Inspiriert von this tutorial
hoffe, das hilft!
das ist, was Ihr für http://pandas.pydata.org/pandas-docs/version/0.13.1/generated/pandas.DataFrame.boxplot suchen. html –
Danke @pss Ich bin mir dessen bewusst. Meine Frage bezieht sich speziell auf Punkt-Boxplots. Ich frage mich, ob es einen einfachen Weg gibt, um die Punkte später hinzuzufügen (beachten Sie die Randomisierung der Punkte entlang der x-Achse, um sie leicht zu sehen) –
Verwenden Sie benutzerdefinierte Plot von 'matplotlib', füttern Sie es als pandas.boxplot ein 'ax'-Argument, dann mache ein Dot-Plot in dasselbe Plot. –