473,654 Members | 3,239 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.PlotIte ms.Data(origina l, title="Original ")
plot2 = Gnuplot.PlotIte ms.Data(expecte d, title="Expected ")
plot3 = Gnuplot.PlotIte ms.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)] )
Jun 27 '08 #1
3 6189
On Jun 12, 12:30 pm, arslanbur...@gm ail.com wrote:
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.PlotIte ms.Data(origina l, title="Original ")
plot2 = Gnuplot.PlotIte ms.Data(expecte d, title="Expected ")
plot3 = Gnuplot.PlotIte ms.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)] )
I've no idea about the answer to your question (I don't know how the
Gnuplot module works and I can't *see* anything obviously wrong with
your code), but this line:

if type (original) != type([])

is better written:

if not isinstance(orig inal, list):

Michael Foord
http://www.ironpythoninaction.com/
Jun 27 '08 #2
ar**********@gm ail.com wrote:
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?
Judging from the demo you have to keep a Gnuplot.Gnuplot instance alive. If
you don't, the display window is immediately garbage-collected.
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.PlotIte ms.Data(origina l, title="Original ")
plot2 = Gnuplot.PlotIte ms.Data(expecte d, title="Expected ")
plot3 = Gnuplot.PlotIte ms.Data(actual, title="Acutal")

gp.plot(plot1, plot2, plot3)
return gp
>

----

import Plotting2 #The name of my file...
gp = Plotting2.plot( [(2,3), (3,4)], [(4,5), (5,6)], [(1,3), (4,8)] )
raw_input()

By the way, I recommend that you raise an Exception instead of returning a
special value when plot() cannot deal with the arguments passed to it.

Peter
Jun 27 '08 #3
ar**********@gm ail.com wrote:
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 ()
Replace this by (from
http://wiki.aims.ac.za/mediawiki/ind...Gnuplot_module
)
gp = Gnuplot.Gnuplot (persist=1)
gp('set data style lines')
# Make the plot items
plot1 = Gnuplot.PlotIte ms.Data(origina l, title="Original ")
plot2 = Gnuplot.PlotIte ms.Data(expecte d, title="Expected ")
plot3 = Gnuplot.PlotIte ms.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)] )

--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
Jun 27 '08 #4

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

Similar topics

9
7066
by: rhmd | last post by:
I need to create image files (eg bmp or jpeg) of xy scatter graphs (i.e., graphs in which markers denote individual points; the markers need to be small polygons of various sizes, shapes, colors, shadings, etc. and there are thousands on them on each graph). Have been using MS Excel, but its limitations are unbelievable (only whole number sizes, no way around a 56 color palette, only low quality jpeg files so that when I publish the...
6
4451
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 library is the most suitable for this? 'plot' on parnassus yields 18 hits, but since I have zero experience, I don't know where to start. What makes it difficult is that I have a time axis instead of a simple integer x-axis. Gnuplot doesn't seem...
9
12787
by: Dr. Colombes | last post by:
What is the easiest way to generate some plots and graphs in Python ? Specifically interested in simple histograms and scatter plots with circles and regression lines. Thanks for your suggestions.
4
4543
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 import gplt import scipy.io.array_import #import Gnuplot
8
1703
by: Freddy | last post by:
Hi guys, I have a quick question, I have a program that generates numerical output (as most of the programs), the program is written in C language, and currently I use the "DOS interface to show the output when it is being generated. is there a "short" and "non-complicated" code which plots the data automatically instead of showing the numbers.
1
3168
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 for me t plot the line graph thanks alot Peteroid wrote: > What kind of 'plot' of the data do you want to do? A histogram ca > be done
7
6844
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 the best graph plotting utility in python or linux. Can I write a code in such a way that my python code automatically gives me a graph. I know little about gnuplot. If you know any better tool without much learning curve please tell me in Linux. ...
0
1147
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 server. Currently I test-output the data through Gnuplot.py & Gnuplot. I'm quite confused about http://wiki.python.org/moin/NumericAndScientific/Plotting which would
7
3549
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: import Gnuplot def bestfit(uinput): if not isinstance(uinput, list):
0
8294
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8494
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8596
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4150
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2719
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1924
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1597
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.