def plot_world_with_plotly(world, species_list=None, max_count=<NUM_LIT:1000>):
if isinstance(world, str):<EOL><INDENT>from .simulation import load_world<EOL>world = load_world(world)<EOL><DEDENT>if species_list is None:<EOL><INDENT>species_list = [sp.serial() for sp in world.list_species()]<EOL>species_list.sort()<EOL><DEDENT>import random<EOL>from ecell4_base.core import Species<EOL>positions = {}<EOL>for serial in species_list:<EOL><INDENT>x, y, z = [], [], []<EOL>particles = world.list_particles_exact(Species(serial))<EOL>if max_count is not None and len(particles) > max_count:<EOL><INDENT>particles = random.sample(particles, max_count)<EOL><DEDENT>for pid, p in particles:<EOL><INDENT>pos = p.position()<EOL>x.append(pos[<NUM_LIT:0>])<EOL>y.append(pos[<NUM_LIT:1>])<EOL>z.append(pos[<NUM_LIT:2>])<EOL><DEDENT>positions[serial] = (x, y, z)<EOL><DEDENT>import plotly<EOL>import plotly.graph_objs as go<EOL>plotly.offline.init_notebook_mode()<EOL>marker = dict(size=<NUM_LIT:6>, line=dict(color='<STR_LIT>', width=<NUM_LIT:1>),<EOL>opacity=<NUM_LIT>, symbol='<STR_LIT>')<EOL>data = []<EOL>for serial, (x, y, z) in positions.items():<EOL><INDENT>trace = go.Scatter3d(<EOL>x=x, y=y, z=z, mode='<STR_LIT>',<EOL>marker=marker, name=serial)<EOL>data.append(trace)<EOL><DEDENT>layout = go.Layout(margin=dict(l=<NUM_LIT:0>, r=<NUM_LIT:0>, b=<NUM_LIT:0>, t=<NUM_LIT:0>))<EOL>fig = go.Figure(data=data, layout=layout)<EOL>plotly.offline.iplot(fig)<EOL>
Plot a World on IPython Notebook