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.

2
  • 2
    Check out this relevant question. Commented Jul 15, 2013 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? Commented Jul 15, 2013 at 21:28

1 Answer 1

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')

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.