I want to make a trellis plot of my dataset.
I have 2 categorical variables, minc
and mut
that I want to use as axis of a facet_grid plot. minc
has two values, mut
has two values, so at the end I should get a 2x2 grid.
My problem is that in each of those plots, I want to draw two series, namely NMI_Louvain
and NMI_Infomap
as a function of muw
that come from an aggregate measure of average over the variable trials.
With the code here I get exactly 4 points but if I add facet_grid to split the plots over the variables minc
and mut
then the two series are superimposed!
import pandas as pd
import numpy as np
# Read the dataset
df = pd.read_csv('http://pastebin.com/raw.php?i=JxmAmvsP')
# Remove some useless columns
df = df[[col for col in df.columns if col not in ['beta', 'on','t1','t2','k','maxk','N','NVI_Infomap','NVI_Louvain']]]
agg = df.groupby(['minc','mut','muw']).aggregate(np.mean)
agg = agg.fillna(0)
d1=agg.reset_index()
d2=agg.reset_index()
ggplot(agg.reset_index(),aes(x='muw',y='NMI_Louvain'))+geom_point()+geom_line()
Is ok but not "facet_gridded". If I add facet_grid, one series is missing!
ggplot(agg.reset_index(),aes(x='muw',y='NMI_Louvain'))+geom_point()+geom_line()+facet_grid('mut','minc')
I'm using Pandas 0.14 + ggplot 0.58 + ipython 2.1