I have gnuplot(version 4.6 patchlevel 5) on Windows 8. I would like to set encofing utf8. I save my source in UTF8 encoding. My source test.txt:
set terminal pdf enhanced size 16cm,8cm font ", 10"
set output "Slozitost/Slozitost.pdf"
set encoding utf8
set grid
set datafile separator ","
set title "Složitost" font ",10"
set key left top title "Legenda" box
set xdata time
set timefmt "%d/%m/%Y"
set xrange ["03/01/2009":"20/04/2014"]
set format y "%10.0f"
#set yrange [-50:14000000]
set format x "%m/%y"
set xtics 6*30*24*60*60
#set ytics 100
set lmargin 13
set rmargin 2
set style fill transparent solid 0.5 noborder
plot 'Slozitost.csv' using 1:2 title "Slozitost" with lines linecolor rgb "blue" lw 3
I tried compile source by gnuplot terminal. Gnuplot terminal said to me this error:
gnuplot> load "test.txt"
^
"test.txt", line 1: invalid character »
What is wrong??
I think this happens if your file has a BOM marker at the beginning. Gnuplot cannot handle this. To remove that, see the documentation of your editor.
If this is the source of the error, the code should work fine if you copy and paste it into the interactive terminal.
BTW: There is no need to post such a big script which we cannot run (we don't have the data file). A minimal script which could show the problem would be something like
set encoding utf8
plot x title "Složitost"
which would also narrow down the source of your problem :)
Related
everybody:
I'm having problems when it comes to representing the data in the form of a histogram.
I do not know very well how to clearly express what I intend, but my idea is:
3 groups of columns (carbides, borides and nitrides)
in each group of columns, 4 columns (hafnium, zirconium, titanium and
tantalum) each with a grid type.
So far, I have done what appears below, but it does not allow me to continue
My current code is:
reset
fontSpec(s) = sprintf("Times-Roman, %d", s)
set term post eps enhanced fontSpec(16)
set output 'TVsG.eps'
set grid
set auto y
set auto x
ticsFont=fontSpec(16)
set xtics font ticsFont
set ytics font ticsFont
set ylabel "Temperature" font fontSpec(25) offset char -1,0
set xlabel "Group" font fontSpec(25) offset 0,char -1
set style fill pattern border -1
set style data histograms
set boxwidth 1.0
set style histogram clustered gap 1
keyFont=fontSpec(18)
set key spacing 2 font keyFont
set key at graph 0.25, 0.9
fn(v) = sprintf("%.1f", v)
plot \
for [COL=2:4] 'data.txt' using COL:xticlabels(1) title columnheader fs
pattern 2, \
'data.txt' u ($0-1-1./6):2:(fn($2)) w labels font fontSpec(14) offset
char 0,0.5 t '' , \
'data.txt' u ($0-1-1./6):2:(fn($3)) w labels font fontSpec(14) offset
char 0,0.5 t '' , \
'data.txt' u ($0-1+1./6):3:(fn($4)) w labels font fontSpec(14) offset
char 0,0.5 t ''
and my data file
Material Hafnium Zirconium Titanium Tantalum
Carbide 3958 3400 3100 3768
Boride 3380 3245 3225 3040
Nitride 3385 2950 2950 2700
The main problem I have now is the following error:
gnuplot> load 'gnuplot2.txt'
"gnuplot2.txt" line 34: warning: Cannot find or open file "data"
"gnuplot2.txt" line 34: warning: Cannot find or open file "data"
"gnuplot2.txt" line 34: warning: Cannot find or open file "data"
"gnuplot2.txt" line 34: warning: Cannot find or open file "data"
"gnuplot2.txt" line 34: warning: Cannot find or open file "data"
"gnuplot2.txt" line 34: warning: Cannot find or open file "data"
"gnuplot2.txt" line 34: No data in plot
Now I'm at a point, I do not know how to continue
Gnuplot does not find the data file. I see two possible reasons:
The name of the datafile is wrong
The script has something like plot "data.txt", the error message mentions a file "data", note the missing .txt. => Check your script and the actual file name, it might be a simple typo or a missing file extension.
The data file is not in the directory where it is expected.
Add the command pwd (print working directory) as the first command in your script. It will print the directory where it expects the data file. If it is not the correct directory, you can:
move or copy your data file to this directory
use the cd command to change to correct directory
start gnuplot from the correct directory
use the plot command with the file name including path information
You use the load command and gnuplot seems to find the script. So I think most probably the data file should be in the same directory as the script gnuplot2.txt.
So far, this is the image that I have
Indeed, the problem was when selecting the directory in which the data was.
The problem now is that I do not know how I can change the format to give it a different color. Besides, I want to add the compound label on top of each column.
Any suggestions?
I have a fortran code as below
program compute_plot
integer :: i, n = 10
real :: x(10), y(10)
x(1) = 0.0
y(1) = 0.0
do i = 2, n
x(i) = 0.1*i
y(i) = x(i)*x(i)
end do
open(unit = 5, file = 'data.txt')
do i = 1, n
write(5,*) x(i),y(i)
end do
close(5)
call system('gnuplot -p data_plot.gnu')
end program compute_plot
and another gnuplot script as below
reset
set terminal pngcairo dashed enhanced size 480,360 font 'arial,12' fontscale 1.0
set encoding utf8
set output 'plot.png'
set xlabel "x"
set ylabel "y"
m = "./data.txt"
set title 'The parabola'
plot m using 1:2 w l
These two code work well in Linux terminal, but I could not find a way to make them work in Windows command prompt. I also not sure if it is possible to make them work in Windows. Please advise.
Download gp503-win32-mingw.zip from gnuplot official webpage;
Extract the zip file in your desired folder, e.g. F:Document;
The gnuplot folder will now have the path of F:\Documents\gnuplot\;
Right click This PC, click on Properties, click on Advanced system settings, click on Advanced tab, click on Environment Variables...;
Choose Path on the top table of Environment Variables windows, then click Edit...;
Now click on New to add in the path of gnuplot.exe, e.g. in my desktop F:\Documents\gnuplot\bin
To check if it is working properly, go to Command prompt and run the command of gnuplot.
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
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
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 }