Animate multiple files with gnuplot - animation

Say I have 'file1.asc', 'file2.asc' ... 'file 20.asc'. For each of these file, splot command in gnuplot represents an ellipsoid.
But I want to animate stacking all these files on a single plot and see these different ellipsoid.
I tried commands like:
do for [i=1:20] {splot 'data'.i.'.asc' using 4:5:6 with lines}
or
splot for [i=1:20] 'data'.i.'.asc' using 4:5:6 with lines
but none of them shows a continuos animation. I this command in a script "try". And the entered "gnuplot try" on command prompt. But no luck.

In order to get a rather smooth animation you must introduce a little delay between two plots with the pause command:
do for [i=0:10] { plot i*x title sprintf('%d', i); pause 0.5 }
In the same way, for your file you'll need
set style data lines
do for [i=1:20] { splot sprintf('data%d.dat', i) using 4:5:6; pause 0.5 }

Related

Crop an image using a specific x, y coordinate in AppleScript

I was able to crop using the top - bottom padding and left - right padding, but how do we crop a specific region of interest from the image using AppleScript, like for example , if the total dimension of the original image is 1000*1000 , and I want the region from {200, 150 , 600 , 600 }
I do not believe it is possible to crop an arbitrary part out of an image with either Image Events or sips "Scriptable Image Processing System".
If anyone knows different, kindly ping me and I am happy to stand corrected.
If you don't want to install any software on your Mac, you can achieve what you want with a small PHP script as it comes with GD installed to do the image processing. That will look something like this:
#!/usr/bin/php -f
<?php
$im = imagecreatefromjpeg("image.jpg");
$crop_area = array('x'=>200,'y'=> 100,'width'=>600,'height'=>600);
$result = imagecrop($im, $crop_area);
imagejpeg($result,"result.jpg");
?>
Of course, you can put that in a script, say "cropper.php" and call it from Applescript with:
do shell script cropper.php
and you can also accept parameters so that you can pass in the name of the image, the crop geometry and the output filename.
Another option might be to install ImageMagick which you can do with homebrew by running:
brew install imagemagick
You can then use ImageMagick like this:
magick input.jpg -crop 600x600+200+150 result.jpg
You can call that from Applescript with:
do shell script "magick ..."
just the same as the PHP version above.

gnuplot unable to output image

I am trying to plot two column data. using first column as label of x axis (configuration) and and the seconds column as the value for the y axis(average_ mpki).
This is how my data looks like:
#assoc_valr blk_sz, cache_sz, rep_pol, avg_icache_mpki
4a128b32c1r 0.000682
4a128b32c2r 3.030329
4a128b16c1r 0.0333616
4a128b16c2r 0.0307207
4a64b32c1r 0.0125913
This is my ploting script:
# Gnuplot script file for plotting data in file "confs.out"
# This file is called confs.p
set style data histogram
set style fill solid border -1
filename="confs.out"
set boxwidth 0.15
set xlabel "Configurations"
set ylabel "Average MPKI"
set xtic rotate by -45 scale 0
set output "confs.png"
set terminal png size 1200,1200
plot "<(sed -n 'confs.out')" using 2:xtic(1) with histogram
I try plotting but it doesn't work, It doesn't throw any warning or error message but still it doesn't generate the output file for me. I can't see output when I try ploting without using the script also. I tried to gather windows to see if it is hidden under my terminal but it is not.
I also tried replacing the space separator with the tab in the data. Still not working.
gnuplot> load 'confs.p'
^C
gnuplot> plot 'confs.out' using 2:xtic(1) with hist
gnuplot> exit

Gnuplot: Making gif animation file with 1500 data files

I have a sequence of 1500 data files named like: 1.dat, 2.dat.....1500.dat, and I want to use gif terminal in gnuplot to make a gif file. I wrote a script to do this, which works pretty good if the number of the data file is not too large. When I tried to make a gif file using 1500 datafiles, the output is a broken file that can not be opened
I post my code as follow, the out.plt file is used to set up gif terminal and then load "loop.plt"; "loop.plt" is used to looping over all the data files:
#start of out.plt file
#This is used to load the loop file
#set up basis config
i=1
n=1500
set title "Suppressing Spiral Wave with Planar Wave"
set size ratio 1
set terminal gif animate delay 15 loop 1500
set output "control_spiral1.gif"
load "loop.plt"
set output
#end of out.plt file
and here is the loop.plt file:
#start of loop.plt
#This is the loop file to plot all data files
set pm3d map
set palette gray
splot sprintf("%d.dat",i) matrix
i=i+1
if(i<=n) reread
#end of loop.plt

Change font color in batch file based on a condition

I am looking for a command in batch script that can change the font color based on a result. its like this:
The batch script is used to check a date condition & if it succeeds, copy the files from 1 folder to another. If not it says "0 files copied. File not found".
My requirement is that this "0 files copied. File not found" message alone should come out in red color so that it is easy to catch it.
Appreciate any help on this!
As I said in my comment, there are several ways to do it. My personal favorite:
set "write=powershell write-host -foreground"
%write% red this failed
%write% green success
you can get valid colors with powershell help write-host (or you can use numbers like color /? for example %write% 13 magenta)
Just before displaying the '0 files copied' message, put this command:
color 04
I assume you'll want to return the color of the screen to the default afterwards. You'll probably have a pause at the end of the batch file. After the pause, put:
color

Script Gnuplot on windows OS

I would like to automate the generation of graphs from a list of data files.
More details :
I have a directory that contain all my data files. I need to generate a graph for each of these files (hundreds). I have a gnuplot file to generate one graph but the name of the data file is specified into the gnuplot script.
For example :
plot 'myfile' index 1 using 1:2 with linespoints pointtype 2 linecolor rgb "green" title "leg"
I need to be able to replace "myfile" by a variable name that can be iterated on all the files of my directory.
You could have a (Windows) batch file with the following command:
for %%G in (*.dat) do gnuplot.exe -e "fn='%%G'" script
This will run gnuplot (and script) for every .dat file in the current directory.
The -e switch is used to input variables via command line (here the filename, surrounded by quotes in case it contains spaces).
If you want to run this command directly from the shell (as opposed to within a batch file), remove one of the % symbols from each of the two pairs.
Within the script file:
plot fn index 1 using 1:2 with linespoints pointtype 2 linecolor rgb "green" title "leg"
If the data files have a "normalized" name (e.g. data1.dat, data2.dat...) take a look at https://stackoverflow.com/a/14947085/3235496
In general you can iterate over many files inside gnuplot as follows:
set terminal pdfcairo
list = "fileA fileB fileC"
do for [file in list] {
set output file . '.pdf'
plot file
}
That kind of iterations requires at least version 4.6.0. In this example you have a fixed list of file names (these are not allowed to contain white spaces).
On Windows you could use
list = system('dir /b *.txt')
to get such a list containing all .txt files in the current directory. Note, that you must use wgnuplot_pipes.exe for this to work.
On a Unix system you could use
list = system('ls *.txt')

Resources