how to use tsplot with FacetGrid in seaborn in Python?
<p>i'm trying to use <code>tsplot</code> in seaborn to plot timecourse data in a <code>FacetGrid</code>. i have two experiments, "A" and "B", each having time course measurements for two individuals (<code>bob</code> and <code>joe</code>) with three replicates. i want each subplot of the grid to contain a <code>tsplot</code> for a given experiment (where each individual gets a different color and where the confidence intervals are derived from the replicates. the data is below.</p>

<p>the code is:</p>

<pre><code>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()
</code></pre>

<p>it gives the error: <code>TypeError: tsplot() takes at least 1 argument (5 given)</code>. </p>

<p>how can this be properly plotted?</p>

<p><strong>update</strong>:</p>

<p>I found that this requires <code>map_dataframe</code>. my new code is:</p>

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

<p>this works except that it doesn't get the colors right:</p>

<p><a href="https://i.stack.imgur.com/WaS3n.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WaS3n.png" alt="colors not showing up in tsplot with facetgrid"></a></p>

<p>how can this be corrected?</p>

<p>--</p>

<p>the data is <code>data.txt</code>:</p>

<pre><code>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
</code></pre>