# -*- coding: utf-8 -*-

__author__ = "Linwei Li"

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import json
from settings import H, E, M, wordsOfEachTopic as wot, T

from settings import outputDir

def showTopic(jsonFile):
    with open(jsonFile) as f:
        data = json.load(f)
    fig, axs = plt.subplots(data['E'], data['H'], figsize=(8, 6), sharex=True)
    fig.suptitle('H:%d E:%d M:%d wot:%d' % (H,E,M,wot))
    n_het = np.array(data['topic'])
    x = np.arange(T)
    for e in range(data['E']):
        for h in range(data['H']):
            sns.barplot(x, n_het[h,e,:], palette="Set3", ax=axs[e][h])
            axs[e][h].set_ylabel("counts")
            axs[e][h].set_title("h:%d e:%d" % (h,e))
    plt.show()

@@ -129,16 +129,32 @@
 rt json%0A
+import argparse%0A
 from set
@@ -572,24 +572,81 @@
 data%5B'H'%5D):%0A
+            print len(x), np.shape(n_het), np.shape(axs)%0A
             
@@ -800,16 +800,16 @@
  (h,e))%0A
-
     plt.
@@ -815,8 +815,218 @@
 .show()%0A
+%0Aif __name__ == '__main__':%0A    parser = argparse.ArgumentParser()%0A    parser.add_argument('json_file', type=str, help='input file in json format')%0A    args = parser.parse_args()%0A%0A    showTopic(args.json_file)%0A

make plot.py a command line tool