RRDTool: Cannot plot line or area (plot empty) - linux

I've been trying to get to grips with RRDTool. Aside from the data acquisition and storage, I'm having trouble plotting anything at all.
Using it like this doesn't return anything, i.e. no png is created:
rrdtool graph graph.png --end now --start end-60 DEF:in=teams.rrd:in:AVERAGE LINE2:in#000000
The only way to get any output is to include something like GPRINT:
rrdtool graph graph.png --end now --start end-60 DEF:in=teams.rrd:in:AVERAGE LINE2:in#000000 GPRINT:in:AVERAGE:"%8.2lf %s Bytes"
But even then, the graph itself is empty, while the GPRINT prints the correct value. I've also tried my luck with plotting a constant value and using HRULE, to no avail. I've tried pretty much everything, manually specifying start and end as well as upper and lower limits.
This is on Debian Squeeze and Ubuntu 11.04.
Update:
Nevermind, I "solved" my problem. Turns out it had something to do with shell-expansion, and putting quotes around the "LINE:in:#000000" was sufficient. Stupid mistake.

Related

Gnuplot won't open window when called via CPP file

I'm trying to get some practice with C and C++ by playing with gnuplot, but whilst following an example on plotting a simple 2 column data file, I encountered an issue.
When I call gnuplot in my script, it refuses to open any window, and doesn't appear to do any work at all. I don't think this is an issue of window persistence, as I don't even see it open for a split second. I've tried fiddling with setting a persistent terminal and pausing after plotting to no avail. My CPU's activity meter never spikes as it does when I run my other example functions, leading me to believe it never opens in the first place.
However, the strangest part to me is that I managed to plot the data file with gnuplot just how I'd hoped to, but the only way I was able to get it to work was running gnuplot as a terminal command via system().
Below is my function I'm testing with. As the comments note, that system call seems to work perfectly, but I'd prefer to use gnuplot "regularly," not via system calls.
void ex2() {
Gnuplot gp("\"C:\\Program Files\\gnuplot\\bin\\gnuplot.exe\"");
// system("gnuplot -p -e \"plot '2col.dat'\""); #works for some reason?????
gp << "plot '2col.dat'\n";
std::cin.get();
}
I'd appreciate any help you can offer! I just want to be able to plot the file with the "gp <<" notation. I apologize if this is similar to another thread here, but every similar one I've found was solved by adding "pause mouse close" at the end or changing the terminal persist setting, which have not worked for me.

AlphaData alternative in Matlab

In Matlab I'm plotting a matrix (let's call it M) using imagesc over an image using imshow. I would like M to have a degree of transparency so I can actually see the image below. This is what I'm doing:
imshow(img); hold on;
h = imagesc(M);
set(h,'AlphaData',0.4); % set transparency to 40%
However, the last line generates an error when running it on Linux. I've been trying to solve it but nothing seems to work. I wonder if there is an alternative to the "AlphaData" property to make it transparent. Thanks!
EDIT: I'm using Matlab R2014a and Java 1.7 on a Linux CentOS 6.6
As Luis Mendo suggested, I just needed to change the renderer. You can:
>get(gcf,'renderer'); % to see which render engine is Matlab using
>set(gcf,'renderer'); % to get a list with all the possible renderers in your machine
So, at least in Linux, to change the renderer it's necessary to start Matlab from terminal by calling it as:
matlab -softwareopengl
Once this is done, setting transparency in an specific plot, as shown in the description of the question, is possible.

is gnuplot fit influenced by terminal?

i have a gnuplot script file to fit measurement data, using this structure:
set terminal png
...some format templates...
f(x) = a + b*x + c*x**2
fit f(x) "datafile.txt" using "X":"Y" via a, b, c
...some plotting commands etc...
with this, gnuplot shows some strange behaviour:
when i run the script as-is, it gives me the following error:
Undefined value during function evaluation
"myscriptfile.gnuplot", line 5: error during fit
when i move the set terminal png line after the fit line, it runs without a hassle.
normally, i'm loading this at the beginning of a master script containing format templates and further data processing routines. doing this also gives me the aforementioned error message, even with the moved set terminal command.
since this is just the first part of processing my data i really need it to work from the master script... i already tried setting initial guesses, FIT_LIMIT and loading it from a gnuplot environment. i'm using gnuplot 4.6.5.
does anyone know how to solve this or how fit gets influenced by other commands? or is this some kind of bug?
edit: uploaded a stripped down version of scripts and data files to here. with the reduced data files the computed fits don't concur with the measured points, but with the complete data they do.
I'm not sure, what the real error is, but it seems to be related to your use of using "PHEAT":"RHOT", although that should be fine.
I could reproduce your error with the following minimal setup:
A data file test.dat:
A B
1 2
2 3
3 4
and a file test.gp:
f(x) = a*x**2 + b*x + c
fit f(x) 'test.dat' using "A":"B" via a,b,c
If I call this file with gnuplot test.gp I get the same error as you. It doesn't appear if I use using 1:2. If I paste the code in an interactive terminal, the error also appears, but only once. If I repeat only the fit command again, it works fine. I'll report this as a bug.
In the script you posted, I was also able to fix this by using using 9:8 instead of using "PHEAT":"RHOT". Additionally you must remove the first line of the data file, which can be done on-the-fly with tail, so that you can leave the using statements of the plot unchanged. So you can use:
fit rhotside(x) "< tail -n +2 testdata.txt" using 9:8 via rhot0, rhot1, rhot2
fit rcoldside(x) "< tail -n +2 testdata2.txt" using 9:8 via rcold0, rcold1, rcold2

How do you programmatically - or from CLI - rotate a PDF?

What I need to be able to do is to rotate a PDF clockwise or counter clockwise either programmatically or from the CLI.
I have spent considerable time researching and attempting to rotate PDFs with GhostScript (as GS is already installed for other reasons) to no avail, nothing seems result in any rotation.
I have looked into using pdftk but it requires java libraries, and I would rather not have java installed on the system.
We've even looked at modifying the PDF file ourselves, and we have had some success with this, but we haven't come across a reliable method that works for all PDFs.
So my #1 preference would be to achieve this with existing resources on the system.
My #2 preference would be to do a little modification to the existing system as possible to achieve this.
The server in question is using Linux (OpenSuse 11) with PHP 5.2 and I have Ghostscript 9.0 installed.
Any advice would be much appreciated.
You can use pdfpages LaTeX package
\documentclass{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[angle=45]{document.pdf}
\end{document}
The LaTeX document above, compiled via pdflatex, produces a document rotated 45 degrees.
There are also tools (wrappers of pdfpages) like pdfjam that can be used directly from command line:
$ pdfjam --suffix rotated45 --angle 45 --fitpaper true document.pdf
There is a way to do this with ImageMagick, if that's available to you.
Example:
$ convert originalfile.pdf -rotate <cw_angle_degrees> newfile.pdf
Note, however, that since this is a raster-based rotation, there will (generally) be a noticeable loss of quality AND increase in filesize.
You haven't said how you are trying to do this with Ghostscript, but if you want to use the pdfwrite device you will need to set /AutoRotatePages=/None or it will rotate the final page so that the majorty of any real text is horizontal.

Print Plot in Octave in Background

Currently, I use print -dpng foo.png to print a plot to file in Octave 3.0.1 on Ubuntu.
Sometimes, I generate thousands of images in a loop.
Whenever a new image pops up, it grabs the mouse control precluding me from multitasking.
Is there anyway to print silently or quietly?
It would be easier to answer your question with a little more information about what you are doing. But with a little guessing maybe this is what you need:
f = figure
set(f, "visible", "off")
plot([1,2,3,4])
print("MyPNG.png", "-dpng")

Resources