0

Okay, so I'm trying to plot these two equations that are supposed to give me a range of curves with varying values for both of them.

What I want to do is plot y = c1 * (1.05^k) + c2 * (0.55^k) * 5, vs y = c1 * (1.05^k) * 1.3 + c2 * (0.55^k) for different values of c1 and c2. k is a value for the time, so I think k should also follow a range.

I've added my code, and I know where my problem is coming from (appending the lists basically), but can someone explain a simple way I can make it work otherwise and plot separate curves instead? Can I have the values of Y1 and Y2 be stored in a 2d array and work with that? Or should I make a function? (I tried making a function first but it wasn't working at all, so I sort of deleted that). But yeah, any suggestions or help on how to do this would be appreciated!

y1 = []
y2 = []

plt.figure(figsize= (16,10))
for c1 in range (-10, 10, 2):
    for c2 in range (-10, 10, 2):
        for k in range (0, 50):
            Y1 = c1*1.05**k + c2*(0.55**k)*5
            y1.append(Y1)
            Y2 = c1*(1.05**k)*1.3 + c2*(0.55**k)
            y2.append(Y2)

plt.plot(y1, y2)
3
  • How is matplotlib supposed to know you want multiple lines? All it can see is the two lists full of data, y1 and y2. If you want separate curves, plot separate lists Commented Dec 14, 2021 at 23:54
  • A hint: look at this question. Note how the plot statements in the second code sample in the question are inside the loop Commented Dec 15, 2021 at 0:03
  • Ahahah yeahhh, that's why I said I knew exactly what the problem was, I just couldn't figure out a way around it. BUT!!! The link you sent is really helpful!! Thank you! Commented Dec 15, 2021 at 2:45

0

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.