Hi,
I´m using Gnuplot via gnuplot.py and I´m looking for a way to get the
plotting output (terminal set to png in my case) piped in a string
instead of to stdout or a file.
Is there any method in gnuplot.py that does this for me?
If not, I tried something like:
p=Gnuplot.Gnuplot(debug=1)
p('set terminal png')
oldstdout=sys.stdout
output=cStringIO.StringIO()
sys.stdout=output
p.plot([[1,0],[2,50],[3,0],[4,20],[5,0],[6,30],[7,70], [8,70], [9, 75],
[10, 50], [11, 30], [12, 50]])
sys.stdout=oldstdout
print output.getvalue()
But unfortunately I also get other stuff like:
"gnuplot: unable to open display ''
"gnuplot: X11 aborted"
in the same string
Can anyone help me on this?
Thanks,
Nicola 1 3301
On 2005-08-18, Nicola Kaiser <Ni***********@urz.uni-heidelberg.de> wrote: I´m using Gnuplot via gnuplot.py and I´m looking for a way to get the plotting output (terminal set to png in my case) piped in a string instead of to stdout or a file.
Plotting to a file and then reading the file is pretty trivial:
import Gnuplot,time
filename = 'foo.png'
p = Gnuplot.Gnuplot()
p('set term png')
p('set out "%s"' % filename)
p.plot('sin(x)')
p('set out')
time.sleep(0.1) # wait for gnuplot to process all the commands
s = open(filename,'rb').read()
Since gnuplot is running asycnronously and reading commands
from a pipe, you've got to give it some time to finish
executing the commands before you attempt to read the file.
Is there any method in gnuplot.py that does this for me?
I don't think so.
If not, I tried something like:
p=Gnuplot.Gnuplot(debug=1) p('set terminal png') oldstdout=sys.stdout output=cStringIO.StringIO() sys.stdout=output p.plot([[1,0],[2,50],[3,0],[4,20],[5,0],[6,30],[7,70], [8,70], [9, 75], [10, 50], [11, 30], [12, 50]]) sys.stdout=oldstdout print output.getvalue()
That's not going to work.
The gnuplot engine isn't a Python program. It's not writing to
sys.stdout, it's writing to Unix file descriptor 1. In order
to do things the way you're attempting to, you'd have to
redirect file descriptor 1 to a pipe before you start the
gnuplot engine, then read the plot data from the pipe.
The Gnuplot module may already be redirecting the gnuplot
processes output file descriptors, so attempting to do it
yourself might not work anyway.
But unfortunately I also get other stuff like:
"gnuplot: unable to open display '' "gnuplot: X11 aborted"
in the same string
Can anyone help me on this?
You shouldn't have gotten messages about the X11 terminal
driver if you really had set the terminal type to png.
--
Grant Edwards grante Yow! Are you selling NYLON
at OIL WELLS?? If so, we can
visi.com use TWO DOZEN!! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ¶}¾Ç¤F¶Ü? |
last post by:
I'm trying to write a script to pass a file of stock prices and volumes,
and plot the results on a gnuplot graph which is non-overlapped graph.
Fig. 1
------------
Fig. 2
Figure 1 is a graph...
|
by: Rama Calaga |
last post by:
Hi, I use both python and gnuplot a lot, but I am
unable to find a way to embed gnuplot "window/canvas" into tkinter. BLT option in
PMW is not so powerful and not so great, any suggestions ??
...
|
by: Alythh |
last post by:
I just installed Chart::Graph::Gnuplot, and I'm fairly satisfied.
But...
My wish is to be able to make a gnuplot() call, make it display the
graph, and stay there while other data becomes...
|
by: Joseph Suprenant |
last post by:
Hello all,
I have a C++ program, it does some calculations on things and then
prints out a file in the format in which GNUPLOT can use. So my question is
how would i call GNUPLOT from my C++...
|
by: Sanyi Benczik |
last post by:
Is there a standard way in C++ to call an external program or is this
platform dependent?
If it is platform dependent, can somebody drop a line what to use or
where to look for info for GNU C++...
|
by: Alexander Stippler |
last post by:
Hello,
I want to visualize numerical results with gnuplot. The easiest way would be
to
use a pipe to gnuplot. But I want to be platform independent, just relying
on
the C++-standard. What is...
|
by: Bernhard Hidding |
last post by:
Hello,
my c++ programm produces a variable number of ASCII files with variable file
names. These are to be plotted in with gnuplot. I use
system("gnuplot -persist my_gnuplot_script.gpl");
to...
|
by: Anton81 |
last post by:
Hi,
it seems to be a FAQ, but I still haven't found a solution. I want to
control gnuplot with a python program. The following at least gives me the
gnuplot output:
...
|
by: Peter Beattie |
last post by:
I am trying to plot something in gnuplot 4.2 using co-ordinates a Python
2.5 program computes. Here's what I'm doing:
pyfrom subprocess import *
pyplot = Popen("c:/progs/gp/bin/wgnuplot.exe",...
|
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...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
| |