Plotting Graphs using Gnuplot
Hello. Was trying to create a simple plotting function. Wasnt working
however. If i write the same code without putting it inside a function
it works. :S. Could some1 tell me the problem? Heres the code:
# File name Plotting2
import Gnuplot
def plot(original, expected, actual):
if type (original) != type([]):
return False
else:
gp = Gnuplot.Gnuplot()
gp('set data style lines')
# Make the plot items
plot1 = Gnuplot.PlotItems.Data(original, title="Original")
plot2 = Gnuplot.PlotItems.Data(expected, title="Expected")
plot3 = Gnuplot.PlotItems.Data(actual, title="Acutal")
return gp.plot(plot1, plot2, plot3)
import Plotting2 #The name of my file...
Plotting2.plot( [(2,3), (3,4)], [(4,5), (5,6)], [(1,3), (4,8)] )
--
http://mail.python.org/mailman/listinfo/python-list
Plotting Graph Functions using Gnuplot
Hello. Needed some help again. Im trying to calculate the best fit line here. Given a set of points in a list. However, wirte in the end where i plot the line it tells me tht the variable is not defined. Either try correcting this or tell me a subsitute that i could use. Thnks. Heres the code: #File name Bestfit.py import Gnuplot def bestfit(uinput): if not isinstance(uinput, list): return False else: sigmax = sigmay = sigmaxy = sigmaxwhl = sigmaxsq = 0 for i in range(len(uinput)): n = len(uinput) sigmax = uinput[i][0] + sigmax sigmay = uinput[i][1] + sigmay sigmaxy = uinput[i][0] * uinput [i][1] + sigmaxy sigmaxwhl = sigmax * sigmax sigmaxsq = uinput[i][0] * uinput[i][0] + sigmaxsq sigmaxsigmay = sigmax * sigmay num = sigmaxsigmay - (n * sigmaxy) den = sigmaxwhl - (n* sigmaxsq) num2 = (sigmax * sigmaxy) - (sigmay * sigmaxsq) gradient = num / den intercept = num2 / den m = gradient c = intercept y = m*x + c plot (y) --- import Bestfit Bestfit.bestfit([(2,3), (3,8), (5,7), (4,9)]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Plotting Graph Functions using Gnuplot
No help yet? -- http://mail.python.org/mailman/listinfo/python-list
Plotting Graphs + Bestfit lines
Hello. Ive got two functions here. Somehow the program does not go in
to the second function wehn i call it. The bestfit function. Could
some1 help me identify the problem. Heres the code:
import Gnuplot
def bestfit(uinput):
if not isinstance(uinput, list):
return False
else:
sigmax = sigmay = sigmaxy = sigmaxwhl = sigmaxsq = 0
for i in range(len(uinput)):
n = len(uinput)
sigmax = uinput[i][0] + sigmax
sigmay = uinput[i][1] + sigmay
sigmaxy = uinput[i][0] * uinput [i][1] + sigmaxy
sigmaxwhl = sigmax * sigmax
sigmaxsq = uinput[i][0] * uinput[i][0] + sigmaxsq
sigmaxsigmay = sigmax * sigmay
num = sigmaxsigmay - (n * sigmaxy)
den = sigmaxwhl - (n* sigmaxsq)
num2 = (sigmax * sigmaxy) - (sigmay * sigmaxsq)
gradient = num / den
intercept = num2 / den
m = gradient
c = intercept
p = Gnuplot.Gnuplot()
p.plot ('%f * x+%f'%(m,c))
return p
def plot(original, expected, actual):
if not isinstance(original, list):
return False
else:
gp = Gnuplot.Gnuplot()
gp('set data style lines')
# Make the plot items
plot1 = Gnuplot.PlotItems.Data(original, title="Original")
plot2 = Gnuplot.PlotItems.Data(expected, title="Expected")
plot3 = Gnuplot.PlotItems.Data(actual, title="Acutal")
gp.plot(plot1, plot2, plot3)
bestfit(expected)
bestfit(actual)
return gp
---
import Combine #The name of my file...
gp = Combine.plot( [(2,3), (4,8), (5,9), (6,2)], [(1,7), (3,3), (4,5),
(5,6)], [(1,3), (3,10), (4,8), (7,9) ] )
raw_input()
--
http://mail.python.org/mailman/listinfo/python-list
Creating a st line after a specific point in Gnuplot
While using gnuplot.py if id want to make a straight line supposingly y = 3 after the point (2,3) (a point on another line) with the same color as that of the line how wud i do that? -- http://mail.python.org/mailman/listinfo/python-list
Point Of intersection between two plotted functions
Is there anyway one could find ot the point of intersection between any two plotted functions and also display them using gnuplot.py?? -- http://mail.python.org/mailman/listinfo/python-list
Re: Plotting Graphs + Bestfit lines
Umm Tried this out too Laiken heres the error that this gives.. Traceback (most recent call last): File "D:\Questions\Gradient and C\Gnuplot\Combining Best fit and Plotting\combasd.py", line 3, in combine.show_plots([(2,3), (4,8), (5,9), (6,2)], [(1,7), (3,3), (4,5), (5,6)], [(1,3), (3,10), (4,8), (7,9) ] ) File "D:\Questions\Gradient and C\Gnuplot\Combining Best fit and Plotting\combine.py", line 54, in show_plots gp = combine.plot( original, expected, actual) NameError: global name 'combine' is not defined Still confused though i get the instance part ur trying to tell me. -- http://mail.python.org/mailman/listinfo/python-list
Re: Plotting Graphs + Bestfit lines
On Jun 13, 12:13 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Umm Tried this out too Laiken heres the error that this
> > gives..
>
> > Traceback (most recent call last):
> > File "D:\Questions\Gradient and C\Gnuplot\Combining Best fit and
> > Plotting\combasd.py", line 3, in
> > combine.show_plots([(2,3), (4,8), (5,9), (6,2)], [(1,7), (3,3),
> > (4,5), (5,6)], [(1,3), (3,10), (4,8), (7,9) ] )
> > File "D:\Questions\Gradient and C\Gnuplot\Combining Best fit and
> > Plotting\combine.py", line 54, in show_plots
> > gp = combine.plot( original, expected, actual)
> > NameError: global name 'combine' is not defined
>
> > Still confused though i get the instance part ur trying to tell me.
>
> Sorry, it should have been
>
> def show_plots(original, expected, actual):
> gp = plot( original, expected, actual)
> raw_input("first")
> gp = bestfit(expected)
> raw_input("second")
> gp = bestfit(actual)
> raw_input("third")
>
> Peter
Tried that out too. No error however, best fit lines still not being
made on the graph. Only the 3 plot lines show up.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Plotting Graphs + Bestfit lines
Got the problem solved finally. Missed out theses two lines:
plot1 = Gnuplot.PlotItems.Data(original, title="Original")
plot2 = Gnuplot.PlotItems.Data(expected, title="Expected")
plot3 = Gnuplot.PlotItems.Data(actual, title="Acutal")
plot4 = Gnuplot.PlotItems.Func('%f * x+%f'%(bf1[0],bf1[1]), title
= "Expected Best Fit")
plot5 = Gnuplot.PlotItems.Func('%f * x+%f'%(bf2[0],bf2[1]), title
= "Actual Best Fit")
The last 2 ones thnx nyways
--
http://mail.python.org/mailman/listinfo/python-list
Extrapolation In Gnuplot
How would u extrapolate/ extend a given line in gnu plot? -- http://mail.python.org/mailman/listinfo/python-list
Decimals in python
Hello. New to using Python. Python automatically round off watver i calculate using the floor function. How wud i make the exact value appear? Tried out fabs() in the math library but still confused. Cud some1 elaborate on it. -- http://mail.python.org/mailman/listinfo/python-list
Changing Colors in gnuplot.py
Hello, Could some1 tell me how u could change the colours of the different lines that you have plotted while using gnuplot.py. Also how to change the background colour, line thickness etc. Thnx -- http://mail.python.org/mailman/listinfo/python-list
Showing a point in Gnuploy.py
Hello. Could some1 tell me how i could "display" a specific point in gnuplot.py. Supposingly if i have a point of intersection (2,3). How can i show this on the graph? As in how can i write near the point of intersection the value :(2,3). Thnx -- http://mail.python.org/mailman/listinfo/python-list
