def plot(iter_info):
    nI = iter_info.agent_output.grid_nI
    nJ = iter_info.agent_output.grid_nJ
    res = iter_info.agent_output.grid_res
    # Reduce the height
    nI /= 3
    width = toolbox_plotting.mm2inch(nJ*res)
    height = toolbox_plotting.mm2inch(nI*res)
    figure = toolbox_plotting.SlideFigure(width=width, height=height)
    axis = figure.add_subplot('', 111, frameon=False)
    num_capsules = 0
    num_transconjugants = 0
    num_recipients = 0
    num_donors = 0
    for cell in iter_info.agent_output.get_all_cells():
        if cell.species == 'EPS':
            #continue
            cell.color = '0.5'
            num_capsules += 1
        elif cell.species == 'Donor':
            cell.color = 'r'
            num_donors += 1
        elif cell.species == 'Recipient':
            if int(cell.vars['copyNumber']) > 0:
                cell.color = 'g'
                num_transconjugants += 1
            else:
                cell.color = 'b'
                num_recipients += 1
        toolbox_idynomics.draw_cell_2d(axis, cell, total_radius=True)
    print('%d capsules'%(num_capsules))
    print('%d donors'%(num_donors))
    print('%d transconjugants'%(num_transconjugants))
    print('%d recipients'%(num_recipients))
    #toolbox_idynomics.plot_cells_2d(axis, iter_info.agent_output)
    #axis.set_title(r'Biofilm (%s g.L$^{-1}$)'%(solute_name))
    width = nJ * res
    height = nI * res
    base_thickness = 0.25*res
    axis.fill_between([0, width], [0]*2, y2=[-base_thickness]*2,
                                        facecolor='k', zorder=-1)
    axis.set_xlim(-base_thickness, width+base_thickness)
    axis.set_ylim(-base_thickness, height+base_thickness)
    lb, rt = 0.01, 0.99
    figure.subplots_adjust(left=lb, bottom=lb, right=rt, top=rt)
    figure.save(os.path.join(sim.figures_dir,
                'biofilm_%s(%d).png'%(options.solute_name, iter_info.number)))
else:
    species_color_dict = toolbox_idynomics.get_default_species_colors(sim)
    toolbox_idynomics.save_color_dict(species_color_dict, color_dict_path)

nI, nJ, nK, res = sim.find_domain_dimensions()
if options.i_max > 0:
    nI = options.i_max

counter = 0

if options.figure_type == None:
    if options.height > 0: height = options.height
    else: height = toolbox_plotting.mm2inch(nI * res)
    if options.width > 0: width = options.width
    else: width = toolbox_plotting.mm2inch(nJ * res)
    figure = toolbox_plotting.SlideFigure(width=width, height=height)
else:
    script = "figure = toolbox_plotting." + options.figure_type + "Figure("
    if nI > 2 * nJ:
        script += "height='double'"
    elif nJ > 2 * nI:
        script += "double_column=True, height='single'"
    else:
        script += "double_column=True, height='double'"
    script += ")"
    try:
        exec(script)
    except:
        print 'Could not make figure!'
        print script
Exemple #3
0
#!/usr/bin/python
from __future__ import division
from __future__ import with_statement
import numpy
import toolbox_plotting
import toolbox_schematic_new as toolbox_schematic

fig = toolbox_plotting.SlideFigure()
axis = fig.add_subplot('', 111, frameon=True, projection='3d')

#X, Y = numpy.meshgrid([0, 1], [0, 1])
#axis.plot_surface(X, Y, 0.3, color='k', zorder=1)
Y, Z = numpy.meshgrid([0, 1], [0, 0.5])
axis.plot_surface(1.0, Y, Z, color='k', zorder=1)

sphere = toolbox_schematic.Sphere()
sphere.set_defaults(edgecolor='none', facecolor='r', zorder=0)
sphere.set_points((0.5, 0.5, 0.5), 0.5)
sphere.draw(axis)

axis.set_xlabel('x')
axis.set_ylabel('y')
axis.set_zlabel('z')