python - Plot staggered histograms/lines as in FACS -


my question exaclt same this one matplotlib. i'm sure has axes or subplots, don't think understand paradigms (a fuller explanation great).

as loop through set of comparisons, i'd base y value of each new plot set below previous 1 this:

enter image description here

one other (potential) wrinkle i'm generating these plots in loop, don't know how many plots there @ outset. think 1 of things i'm getting hung on subplots/axes, because seems need set them ahead of time.

any ideas appreciated.

edit: made little progress think:

import numpy np  import pandas pd import matplotlib.pyplot plt  x = np.random.random(100) y = np.random.random(100)   fig = plt.figure() ax = fig.add_axes([1,1,1,1]) ax2 = fig.add_axes([1.02,.9,1,1])  ax.plot(x, color='red') ax.fill_between([i in range(len(x))], 0, x, color='red', alpha=0.5) ax2.plot(y, color='green') ax2.fill_between([i in range(len(y))], 0, y, color='green', alpha=0.5) 

gives me: enter image description here

which close want...

is sort of thing want?

stacked plots

what did define y-distance between baselines of each curve. ith curve, calculated minimum y-value, set minimum times y-distance, adjusting height of entire curve accordingly. used decreasing z-order ensure filled part of curves not obscured baselines.

here's code:

import numpy np import matplotlib.pyplot plt  delta_y = .5  zorder = 0 i, y in enumerate(data):   baseline = min(y)   #change needed minimum of y delta_y above previous curve   y_change = delta_y * - baseline   y = y + y_change   plt.fill_between(np.linspace(0, 1000, 1000), y, np.ones(1000) * delta_y * i, zorder = zorder)   zorder -= 1 

code generates dummy data:

def gauss(x):   return np.exp(-x**2 / 2.0)  #create data x = np.linspace(-10, 10, 100) data = [] in xrange(10):   arr = np.zeros(1000)   arr[i * 100: * 100 + 100] = gauss(x)   data.append(arr) data.reverse() 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

apache - setting document root in antoher partition on ubuntu -