2016-05-24 9 views
4

Ich versuche, tsplot in Seaborn zu verwenden, um Zeitfahrdaten in einem FacetGrid zu zeichnen. Ich habe zwei Experimente, "A" und "B", jeweils mit Zeitverlaufsmessungen für zwei Individuen (bob und joe) mit drei Wiederholungen. Ich möchte jedes subplot des Gitters ein tsplot für ein bestimmtes Experiment enthalten (in denen jeder einzelne eine unterschiedliche Farbe erhält und wobei die Konfidenzintervalle von den Replikaten abgeleitet werden die Daten untenWie benutze ich tsplot mit FacetGrid in Seaborn in Python?

der Code ist:..

import matplotlib.pylab as plt 
import seaborn as sns 
import pandas 

df = pandas.read_csv("./data.txt", sep="\t") 
sns.set(style="ticks", color_codes=True) 
plt.figure() 
g = sns.FacetGrid(df, col="t", hue="name", row="experiment") 
g = g.map(sns.tsplot, time="t", value="val", unit="reps", 
      condition="name") 
plt.show() 

es gibt den Fehler:.? TypeError: tsplot() takes at least 1 argument (5 given)

, wie diese richtig aufgetragen

Update werden können:Ich habe festgestellt, dass dies map_dataframe erfordert. mein neuer Code ist:

g = sns.FacetGrid(df, row="experiment") 
g = g.map_dataframe(sns.tsplot, time="t", unit="reps", 
        value="val", condition="name") 

das funktioniert, außer, dass es nicht die Farben rechts bekommt:

colors not showing up in tsplot with facetgrid

, wie diese behoben werden können?

-

die Daten data.txt:

t name reps val experiment 
0 bob 1 3.3 A 
0 bob 2 4.0 A 
0 bob 3 3.8 A 
5 bob 1 6.0 A 
5 bob 2 6.4 A 
5 bob 3 6.9 A 
10 bob 1 9.99 A 
10 bob 2 9.1 A 
10 bob 3 9.0 A 
0 joe 1 2.1 A 
0 joe 2 2.2 A 
0 joe 3 2.5 A 
5 joe 1 4.5 A 
5 joe 2 4.1 A 
5 joe 3 4.0 A 
10 joe 1 6.8 A 
10 joe 2 6.1 A 
10 joe 3 6.2 A 
0 bob 1 2.3 B 
0 bob 2 3.0 B 
0 bob 3 2.8 B 
5 bob 1 5.0 B 
5 bob 2 5.4 B 
5 bob 3 5.9 B 
10 bob 1 10.99 B 
10 bob 2 10.1 B 
10 bob 3 10.0 B 
0 joe 1 3.1 B 
0 joe 2 3.2 B 
0 joe 3 3.5 B 
5 joe 1 3.5 B 
5 joe 2 3.1 B 
5 joe 3 3.0 B 
10 joe 1 7.8 B 
10 joe 2 7.3 B 
10 joe 3 7.2 B 
+0

Könnte [diese Antwort] (http://stackoverflow.com/ a/22798911/5276797) dir helfen? – IanS

+0

@IanS: Nein, es geht nicht um die Interaktion zwischen facetgrid und tsplot, worum geht es in meiner Frage. – mvd

+2

Sie müssen eine Farbpalette zu 'tsplot' angeben, um die Tatsache zu übersteuern, dass' FacetGrid' denkt, dass etwas in einer Farbe gezeichnet wird. 'g.map_dataframe (..., color =" deep ") sollte es tun. – mwaskom

Antwort

0

Die Lösung in @ mwaskom ist Kommentar:

You have to specify a color palette to tsplot to override the fact that FacetGrid thinks it is plotting something in one color. g.map_dataframe(..., color="deep") should do it.

Verwandte Themen