473,503 Members | 3,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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)])
Jun 27 '08 #1
1 1412
No help yet?
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4441
by: Gerrit Holl | last post by:
Hi, I have a dictionairy containing DateTime objects as keys and integers as values. What would be the easiest way to create a simple plot of these, with a number axis versus a time axis? What...
2
2917
by: KevinGPO | last post by:
I am making a monitor program for the PC. My monitor program will grab statistics about CPU and memory every 1 or 5 seconds. Then I want to store this data so I have a history and hence be able to...
4
4539
by: skorpio11 | last post by:
Hi, I've been having some problems trying some basic plotting commands with gnuplot.py. My setup is the Python 2.3 Enthought edition and my script looks as: from scipy import * from scipy...
11
29497
by: Chapman | last post by:
Is it possible to plot the graph as an output of my program in C? It can be a simple graph as quadratic curves for example or a correlation between 2 variables only. Thanks
1
3148
by: wayne | last post by:
i want to plot a line graph. The values that I obtain are the RGB value of a TIFF image. i m plotting RGB values vs value(1,2,3..) so when generated the RGB values, there will b a column of values...
7
6833
by: diffuser78 | last post by:
My python program spits lot of data. I take that data and plot graphs using OfficeOrg spredsheet. I want to automate this task as this takes so much of time. I have some questions. 1. Which is...
0
1141
by: robert | last post by:
What is a good library for plotting graphs to (compressed) gif / jpg images? Has anybody experience with this? I want to put some simple 2D (and maybe 3D) graph data visualization on a web...
3
6176
by: arslanburney | last post by:
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...
7
3542
by: arslanburney | last post by:
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: ...
0
7064
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7315
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7445
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4665
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.