Python Forum
Help rendering a pylab plot
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help rendering a pylab plot
#2
Just vectorize your function and plot it:

from pylab import *
 
# Returns the summer tterature of seawater (in degrees Celsius) according to Mackenzie’s model.
@np.vectorize
def some_function(ff, dd):
    if dd >=0 and dd <=200:
        tt = (22/-90)*ff+24
    elif dd >=200 and dd <=1000:
        st = (22/-90)*(ff)+24
        gg = (st-2)/-800
        tt = gg*dd+(gg*-1000+2)
    else:
        tt = 2.0
    return tt
 
ff = float(25)
dd = np.arange(0, 1200, 100)
tt1 = some_function(ff, dd)
plot(dd,tt1)
title("Something")
xlabel("x label")
ylabel("y label")
show()
Reply


Messages In This Thread
Help rendering a pylab plot - by cyberman - May-12-2019, 02:10 PM
RE: Help rendering a pylab plot - by scidam - May-15-2019, 05:27 AM

Forum Jump:

User Panel Messages

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