def multiple_plot(files, image=True): from openalea.core.path import path from matplotlib import pyplot as plt import rsml def get_file(f): exts = ['.png', '.jpg', '.tif'] fn = f.splitext()[0] for ext in exts: _f = path(fn + ext) if _f.exists(): return _f n = len(files) f, axes = plt.subplots(1, n, sharex=True, sharey=True) f.set_size_inches(7 * n, 5) for i in range(n): fn = files[i] g = rsml.rsml2mtg(fn) if image: plot2d(g, img_file=get_file(fn), axis=axes[i], ms=1) else: plot2d(g, axis=axes[i], ms=1) if not image: ax = axes[0] ax.set_ylim(ax.get_ylim()[::-1])
def rw(fn, display=False): gs = rsml.rsml2mtg(fn) if display: dump = rsml.Dumper() s = dump.dump(gs) print s rsml.plot3d(gs, img_dir='.') return gs
def f2(): rsml.plot3d(gs, img_dir='.') # OK data = shared_data(rsml) / 'rsml' / 'rootnav' files = [fn for fn in data.glob('*.rsml') if 'old' not in fn] fn = files[0] print "read ", fn def get_file(f, ext='.png'): return f.splitext()[0] + ext gs = rsml.rsml2mtg(fn) rsml.plot2d(gs, img_file=get_file(fn))
def f2(): rsml.plot3d(gs, img_dir='.') # OK data = shared_data(rsml)/'rsml'/'rootnav' files = [fn for fn in data.glob('*.rsml') if 'old' not in fn] fn= files[0] print "read ", fn def get_file(f, ext='.png'): return f.splitext()[0]+ext gs = rsml.rsml2mtg(fn) rsml.plot2d(gs, img_file=get_file(fn))
def plot_from_file(rsml_file, ax, split_plant, label=""): g = rsml.rsml2mtg(rsml_file) # extract properties & measurments for all roots root = measurements.root_order(g) # ids of lateral roots root = [r for r,o in root.iteritems() if o==2] length = measurements.root_length(g,root) # length of roots ppos = measurements.parent_position(g,roots=root,distance2tip=True) # branching position on parent plant = dict((r,g.complex(r)) for r in root) # plant id of all roots if split_plant: # plot root length w.r.t parent_position, for each plant for i,pid in enumerate(sorted(set(plant.values()))): rids = [r for r,p in plant.iteritems() if p==pid] x = np.array([ppos[r] for r in rids]) y = np.array([length[r] for r in rids]) plot(x,y,"plant %d"%(i+1)) else: x = np.array([ppos[r] for r in root]) y = np.array([length[r] for r in root]) plot(x,y, label)
def plot_from_file(rsml_file, ax, split_plant, label=""): g = rsml.rsml2mtg(rsml_file) # extract properties & measurments for all roots root = measurements.root_order(g) # ids of lateral roots root = [r for r, o in root.iteritems() if o == 2] length = measurements.root_length(g, root) # length of roots ppos = measurements.parent_position( g, roots=root, distance2tip=True) # branching position on parent plant = dict((r, g.complex(r)) for r in root) # plant id of all roots if split_plant: # plot root length w.r.t parent_position, for each plant for i, pid in enumerate(sorted(set(plant.values()))): rids = [r for r, p in plant.iteritems() if p == pid] x = np.array([ppos[r] for r in rids]) y = np.array([length[r] for r in rids]) plot(x, y, "plant %d" % (i + 1)) else: x = np.array([ppos[r] for r in root]) y = np.array([length[r] for r in root]) plot(x, y, label)