Bottom Page

Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to plot a Graph
Hello, I have an equation and need to plot a graph using the Euler method, the code looks like this:

h = 0.01
x = [0.0]
y = [0]
n = int(30/h)

def f(y,x):
    eq = #something
     return #something

for i in range (0,n):
    xn = (i+1)*h
    yn = y[i] + f(y[i],x[i])*h
    #print (x[i],y[i])
plt.title("Concentration by Time")
But I have an equation, this one:

10(105 + log(900)) -5*t = S^2 /2 +20S +20log(S)

So when t = 0, S = 30. So I need to plot the values of S as the time increase.

Any help how to solve the equation?? In fact, I need anything that use the euler method that allows me to plot the graph.

Thanks in advance!
See this example:
It might help to say what do you mean with "plotting graph using euler method" - euler method usually means numerical method to solve first order ODE - and if you mean this method, then solving ODE and plotting result are two rather separate things.

Anyway your equation is not a differential equation, you can transform it to an explicit form as t = f(S) and then straigtly plot it with matplotlib as Larz60+ suggested. And if you instist on using implicit equation, there is plot_implicit() function in sympy.plotting.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  How to create a new plot in a figure right below the first one after click event? codexx 0 28 Yesterday, 04:45 PM
Last Post: codexx
  How do I make my plot show up? ThomasM4 0 267 Dec-09-2018, 05:28 AM
Last Post: ThomasM4
  Tips on surface plot HW question Cwcox 1 331 Nov-14-2018, 11:45 PM
Last Post: Larz60+
  How to customize x axis in matplotlib.pyplot for a scatter plot? wlsa 9 671 Nov-10-2018, 01:32 AM
Last Post: wlsa
  Adding text to plot Pythcoronas 1 404 Sep-13-2018, 12:27 PM
Last Post: baby_quant
  plot the mean in a bar diagram sussii 3 538 May-23-2018, 11:27 PM
Last Post: wavic
  How to plot date series in matplotlib? StrybolData 2 2,301 Jan-25-2018, 07:13 PM
Last Post: StrybolData
  Removing data in a plot ulrich48155 3 1,406 Jun-19-2017, 06:31 PM
Last Post: zivoni
  matplotlib : Raster Plot adithyakrish 0 1,193 Apr-24-2017, 10:46 AM
Last Post: adithyakrish
  Change the colour of a plot Sito 1 1,063 Apr-13-2017, 10:22 PM
Last Post: zivoni

Forum Jump:

Users browsing this thread: 1 Guest(s)