Python Forum
Substituting Values in Plot
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Substituting Values in Plot
#1
I have an equation I need to plot which generates correctly in another program but not in Python. The equation used in the other program is
syms u; %logarithmic variable
V1 =  %Equation 
xaxis = logspace(0,4); %makes logarithmic points, until 10E4
yaxis = double(subs(V1,u,xaxis)); %changes values by substituting 
(((((Not Actually in Python))))
And My Code in python is
import numpy as np
import matplotlib.pyplot as plt
plt.clf() 
w = np.linspace(0, 10E4, 10E4) 
f1=#eqn 
plt.plot(w, f1)
axes = plt.gca()
axes.set_xscale('log')
axes.set_yscale('log')
axes.set_xlim([0, 10E4])            
axes.set_ylim([0, 10E4])           
plt.show()
The problem I am having is the substitution, in the first program it does a substitution in the equation but my python program does not do so and is generating a wrong graph.
Reply
#2
Your Python code doesn't generate anything, except errors
 w = np.linspace(0, 10E4, 10E4) the third (optional) argument should be an integer, not a float. 
 f1=#eqn is not legal in Python.

Perhaps you can show us the code that actually generates a graph
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
import numpy as np
import matplotlib.pyplot as plt
plt.clf() 
u=5;
E=1000;
w = np.linspace(0, 100000,100000) 
f1= ((w*u)/(np.sqrt(1+(((w*u)/E)**2)))) 
plt.plot(w, f1)
axes = plt.gca()
axes.set_xscale('log')
axes.set_yscale('log')
axes.set_xlim([0, 10E4])            # x-axis bounds
axes.set_ylim([0, 10E4])              # y-axis bounds
plt.show()
This is how my graph should look like:
Image Graph should look
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Matplotlib scatter plot in loop with None values ivan_sc 1 2,234 Nov-04-2021, 11:25 PM
Last Post: jefsummers
  Plot correct values Felipe 9 6,936 Feb-18-2017, 09:21 AM
Last Post: merlem

Forum Jump:

User Panel Messages

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