0

I was having trouble creating a plot I need which has multiple line graphs.

What I want is a way to graph each of these above the other (say one has a baseline of y=5 I want the next to have a baseline of y=10) and also each of these graphs must block the one above it.

So this will inevitably look like the cover to Joy Divisions Unknown Pleasures here: http://cococubed.asu.edu/images/unknown_pleasures/unknown_pleasures.jpg

Except inverted colors and I also would like an answer that utilizes python or numpy or matplotlib.

Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51
Jrosey
  • 15
  • 4
  • 2
    Check out this [relevant question.](http://stackoverflow.com/questions/17614499/frequency-trail-in-matplotlib) – wflynny Jul 15 '13 at 20:32
  • Does each plot must be really stacked on top of each other such as curve 1 is y1, curve 2 is y2+y2, curve 3 is y3+y2+y1 ... and so on? Or is just the baseline that must be added? – user2304916 Jul 15 '13 at 21:28

1 Answers1

3

Here's one way. The key point is to use fill_between function and offset each plotted line with some margin (i*2 in this case). Also, plotting has to start from the top, hence the [::-1] in the arange slice.

t=linspace(-2*pi, 2*pi, 1000)
for i in arange(1, pi, 0.01)[::-1]:
    left = exp(-(t + (i - 1) * 2*pi)**2) * cos(t * i)**2 - 1
    right = exp(-(t - (i - 1) * 2*pi)**2) * cos(t * i)**2 - 1 
    vertical_offset = i*2
    fill_between(t, vertical_offset + left + right, facecolor='white')

numentar
  • 1,049
  • 8
  • 21