0

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

linello
  • 8,451
  • 18
  • 63
  • 109
  • I ran your code (first version: your second has actually two `+ facet_grid()`) with current ggplot head and I get a 2x2 grid. Do you get an error message with `g = ggplot(...) + ...; g.draw()`? – Jan Katins Jun 22 '14 at 22:00
  • No error messages, but I get two 2x2 grids with the same datasets. Very strange. – linello Jun 23 '14 at 07:58

0 Answers0