import matplotlib.pyplot as plt
import os


def data_plotter(lattice_dict, datafile_dir, plot_dir):

    # total spaces on grid implies grid size
    total_cells = lattice_dict['E'][0] + lattice_dict['D_a'][0] + lattice_dict['D_b'][0] + lattice_dict['B'][0]
    n = int(total_cells**0.5)

    plt.figure(1)

    plt.plot(lattice_dict['time'], lattice_dict['E'], label='Empty lattice points')
    plt.plot(lattice_dict['time'], lattice_dict['D_a'], label='Donors (Type A)')
    plt.plot(lattice_dict['time'], lattice_dict['D_b'], label='Donors (Type B)')
    plt.plot(lattice_dict['time'], lattice_dict['B'], label='Debris')

    ax = plt.gca()
    ax.set_title('Cell Populations over time (n = %d)' % n)
    ax.set_ylabel('Number of cells')
    ax.set_xlabel('Time (h)')

    plt.legend()

    f = plt.gcf()
    f.set_size_inches(20.0, 8.0)  # alternative: 20.0, 8.0
    f.tight_layout()
    plt.savefig(os.path.join(plot_dir, 'population_vs_time.png'))
    plt.clf()
    
    return

[((293, 306), 'matplotlib.pyplot.figure', 'plt.figure', (['(1)'], {}), '(1)\n', (303, 306), True, 'import matplotlib.pyplot as plt\n'), ((312, 391), 'matplotlib.pyplot.plot', 'plt.plot', (["lattice_dict['time']", "lattice_dict['E']"], {'label': '"""Empty lattice points"""'}), "(lattice_dict['time'], lattice_dict['E'], label='Empty lattice points')\n", (320, 391), True, 'import matplotlib.pyplot as plt\n'), ((396, 472), 'matplotlib.pyplot.plot', 'plt.plot', (["lattice_dict['time']", "lattice_dict['D_a']"], {'label': '"""Donors (Type A)"""'}), "(lattice_dict['time'], lattice_dict['D_a'], label='Donors (Type A)')\n", (404, 472), True, 'import matplotlib.pyplot as plt\n'), ((477, 553), 'matplotlib.pyplot.plot', 'plt.plot', (["lattice_dict['time']", "lattice_dict['D_b']"], {'label': '"""Donors (Type B)"""'}), "(lattice_dict['time'], lattice_dict['D_b'], label='Donors (Type B)')\n", (485, 553), True, 'import matplotlib.pyplot as plt\n'), ((558, 623), 'matplotlib.pyplot.plot', 'plt.plot', (["lattice_dict['time']", "lattice_dict['B']"], {'label': '"""Debris"""'}), "(lattice_dict['time'], lattice_dict['B'], label='Debris')\n", (566, 623), True, 'import matplotlib.pyplot as plt\n'), ((634, 643), 'matplotlib.pyplot.gca', 'plt.gca', ([], {}), '()\n', (641, 643), True, 'import matplotlib.pyplot as plt\n'), ((776, 788), 'matplotlib.pyplot.legend', 'plt.legend', ([], {}), '()\n', (786, 788), True, 'import matplotlib.pyplot as plt\n'), ((798, 807), 'matplotlib.pyplot.gcf', 'plt.gcf', ([], {}), '()\n', (805, 807), True, 'import matplotlib.pyplot as plt\n'), ((958, 967), 'matplotlib.pyplot.clf', 'plt.clf', ([], {}), '()\n', (965, 967), True, 'import matplotlib.pyplot as plt\n'), ((904, 952), 'os.path.join', 'os.path.join', (['plot_dir', '"""population_vs_time.png"""'], {}), "(plot_dir, 'population_vs_time.png')\n", (916, 952), False, 'import os\n')]