Python Forum
Using a list as a Y value in a python graph
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using a list as a Y value in a python graph
#1

SO I have a function that returns a list and I want to use it as the Y value of a function. I'm currently getting an 'x and y must have the same first value' error. Anyone see the problem in my code?
def y(initialPop, popGrowth):
    y=initialPop
    yList = []
    x=0
    while x < 400:
        yList.append(y)
        y = initialPop * np.exp(popGrowth * (x/4)) - (newsDiscussion(1, 20, x, 0.0015, 0.003, 0.55)*y)-(Tax2(156, 160, x, 0.05775, 0.1155, 0.55)*y)-(Tax1(80, 84, x, 0.77, 0.154, 0.55)*y)-(runVeganuaryMain(x)*y)
        x = x + 1
    return yList[1:400]

x= np.linspace(0, 400, num=400000)
ax.set_title('cumulative decrease in consumption')
ax.set_xlabel('$Quarter$')
ax.set_ylabel('$Percent of the Population$')
ax.plot(x, y(initialPop, popGrowth), 'p-', lw=1, alpha=0.6, label='Major Graph')
Reply


Messages In This Thread
Using a list as a Y value in a python graph - by Afterdarkreader - Dec-13-2017, 07:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Photo How to do a graph in Python? (and proper terminology) jpy 2 2,196 Dec-23-2020, 01:07 PM
Last Post: codeto
  Draw graph (Python) Eberle 1 3,520 May-28-2019, 05:29 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020