Putting latex axis labels through gnuplot and into a latex document - graphics

I have a plot in Gnuplot which includes axis labels in latex font, which compiles to produce a *.tex file AND a *.eps file. When I put the eps file into my latex document, the axis labels simply do not appear at all. When I try to imbed the *.tex file (which references the EPS), I get:
! LaTeX Error: Cannot determine size of graphic in dimensionlessformm5d.tex (no BoundingBox).
What is a BoundingBox and how do I add it in to the *.tex file I want to imbed?

It's difficult to tell with no code, but you should be able to compile without specifying bounding box (are you loading the graphicx package? Use \usepackage{graphicx} in your latex preamble). In any case, you can get a bounding box with
gs -sDEVICE=bbox -dNOPAUSE -dBATCH file.eps
and specify on latex using
\includegraphics[bb = insert 4 bounding box values here]{file.eps}
Post you gnuplot and latex codes if you want more directed advice.

Latex code:
\documentclass[12pt]{article}
\usepackage{amsmath,bm,fleqn,amssymb,graphicx}
\setlength{\topmargin}{0in}
\setlength{\oddsidemargin}{0in}
\setlength{\evensidemargin}{0in}
\setlength{\textheight}{9in}
\setlength{\textwidth}{6.5in}
\setlength{\headheight}{0in}
\setlength{\headsep}{0in}
\begin{document}
\begin{figure}[h!]
\centering
\includegraphics[width=.995\textwidth]{dimensionlessformm5d.tex}
\caption{Dimensionless output 1: Spectral plot of the negative value of the real part of Eq. (\ref{eqn:new22}) in units of $\tau^2 / \gamma_i$ plotted vs. normalized frequency $\omega / \omega_L$ for $\omega_L \tau = 75$ (black curve),250(green),1000(magenta), for a value of the dimensionless initial momentum $p_i / (m^{\prime} c^{\prime})$ of 2.375. Note that the independent variables have been expressed in dimensionless form for ease of scaling analysis. Note also that this is simply the fractional single-pass gain, except lacking the prefactor $e^2 Z_0\dot{n}/(4m)$.}
\end{figure}
\begin{thebibliography}{99}
\bibitem{paper1} Borie, E. "Review of Gyrotron Theory". Tech. no. 4898. Karlsruhe, Germany: Kernforschungszentrum Karlsruhe, 1991. {\it Karlsruher Institut Fuer Technologie.} Web. 21 Nov. 2012. \textless http://bibliothek.fzk.de/zb/kfk-berichte/KFK4898.pdf\textgreater .
\bibitem{paper2} "Efficiency Enhancement of the Relativistic Gyrotron" N. A. Zavolsky, V. E. Zapevalov and M. A. Moiseev (Radiophysics and Quantum Electronics
Volume 44, Number 4 (2001), 318-325, DOI: 10.1023/A:1010422204317) Web. 21 Nov. 2012.
\textless http://www.springerlink.com/content/g15665j442405407/\textgreater .
\bibitem{paper3} Coyne, Kristen. "Magnets from Mini to Mighty." National High Magnetic Field Laboratory. N.p., n.d. Web. 21 Nov. 2012. \textless http://www.magnet.fsu.edu/education/tutorials/magnetacademy/magnets/fullarticle.html\textgreater .
\bibitem{paper4} Min, Hongki. "Electronic Structure of Graphene Graphene Monolayer Graphene Bilayer." Lecture. 11 Oct. 2006. Web. 21 Nov. 2012. \textless http://www.ph.utexas.edu/~macdgrp/meetings/hongki-monolayer.pdf\textgreater .
\bibitem{paper5} “Band gap formation in graphene by in-situ doping” (Appl. Phys. Lett. 98, 203102 (2011) doi: 10.1063/1.3589364)
\bibitem{paper6} “Universal Optical Conductance of Graphite”, Phys. Rev. Lett. 100, 117401 (2008)
\bibitem{paper7} “Intersubband Electroluminescence from Silicon-Based Quantum Cascade Structures” Science 22 December 2000
Vol. 290 no. 5500 pp. 2277-2280
DOI: 10.1126/science.290.5500.2277
\bibitem{paper8} Andronov, Alexander A. "From H. Kroemer and B. Lax to Modern Solid-State (Semiconductor) Cyclotron Resonance Masers." IEEE Transactions on Plasma Science 27.2 (1999): 303-11. Print.
\end{thebibliography}
% To be more explicit about losses, the mirror parameters’ relation to each other, and cavity performance is also
% included via the following equations.
% $CL=1-[(1-MT-MA)(1-GA)]$
% where $CL$ is the cavity loss,
% $MT$ is the mirror Transmission coefficient,
% $MA$ is the mirror Absorption coefficient,
% and $GA$ is the graphene Absorption coefficient.
% and we take the new fields E parallel and E perp to be slowly varying in time compared to the gyration at
% $\omega_{Larmor}$
\end{document}
Gnuplot code:
set term postscript eps enhanced color
set output "C:\\Users\\cole1\\Desktop\\dimensionlessformm5d.eps"
set multiplot
set xtics font "Times-Roman, 20"
set ytics font "Times-Roman, 18"
set size 1,1
set origin 0,0
set xlabel "blahblah"
set xrange [0.35:0.8]
set yrange [-2:1]
plot 'C:\\Users\\cole1\\Documents\\MATLAB\\theorycurves3_1.txt' using 1:2 lc rgbcolor "#000000" with lines notitle, 'C:\\Users\\cole1\\Documents\\MATLAB\\theorycurves3_1.txt' using 7:8 lc rgbcolor "#00FF00" with lines notitle , 'C:\\Users\\cole1\\Documents\\MATLAB\\theorycurves3_1.txt' using 11:12 lc rgbcolor "#FF00FF" with lines notitle
unset label 1

Related

Spacing between points in graph in gnuplot

As can be seen in the picture attached, the points become too cluttered after a certain point. How do I increase the spacing between points in that region?
Code:
set term jpeg size 1800,900
set output "plot.jpeg"
splot "3d_ME2_31.out" us 1:2:3 lc -1
set grid
set output
I have tried the "every" command but it increasing the spacing in the beginning region too where the point spacing is already high.
Any advice is appreciated. Thanks !
Edit: Data file ( the data to axes mapping is 1:2:3 )
0.94652E+03 0.46588E+02 0.82952E-01
0.94871E+03 0.61601E+02 0.16795E+00
0.95102E+03 0.74087E+02 0.29030E+00
0.95587E+03 0.94012E+02 0.65911E+00
0.95850E+03 0.10204E+03 0.91894E+00
0.96148E+03 0.10885E+03 0.12599E+01
0.96515E+03 0.11542E+03 0.17353E+01
0.96943E+03 0.12040E+03 0.23543E+01
0.97481E+03 0.12578E+03 0.32153E+01
0.98134E+03 0.13077E+03 0.43582E+01
0.98901E+03 0.13507E+03 0.58196E+01
0.99795E+03 0.13948E+03 0.76562E+01
0.10082E+04 0.14377E+03 0.99270E+01
0.10199E+04 0.14800E+03 0.12677E+02
0.10282E+04 0.14775E+03 0.14762E+02
0.10335E+04 0.14413E+03 0.16176E+02
0.10403E+04 0.14050E+03 0.18096E+02
0.10488E+04 0.13621E+03 0.20616E+02
0.10588E+04 0.13205E+03 0.23729E+02
0.10710E+04 0.12798E+03 0.27711E+02
0.10843E+04 0.12370E+03 0.32248E+02
0.10995E+04 0.11973E+03 0.37684E+02
0.11163E+04 0.11572E+03 0.43955E+02
0.11324E+04 0.11203E+03 0.50189E+02
0.11474E+04 0.10875E+03 0.56245E+02
0.11626E+04 0.10553E+03 0.62585E+02
0.11781E+04 0.10217E+03 0.69305E+02
0.11938E+04 0.99038E+02 0.76322E+02
0.12094E+04 0.96412E+02 0.83573E+02
0.12252E+04 0.94002E+02 0.91126E+02
0.12411E+04 0.91794E+02 0.98981E+02
0.12571E+04 0.89765E+02 0.10714E+03
0.12732E+04 0.87918E+02 0.11559E+03
0.12894E+04 0.86536E+02 0.12432E+03
0.13054E+04 0.84701E+02 0.13318E+03
0.13213E+04 0.82945E+02 0.14227E+03
0.13373E+04 0.81284E+02 0.15161E+03
0.13533E+04 0.79678E+02 0.16122E+03
0.13694E+04 0.78071E+02 0.17111E+03
0.13855E+04 0.76542E+02 0.18127E+03
0.14008E+04 0.74960E+02 0.19118E+03
0.14159E+04 0.73330E+02 0.20115E+03
0.14309E+04 0.71898E+02 0.21132E+03
0.14458E+04 0.70357E+02 0.22162E+03
0.14607E+04 0.68300E+02 0.23218E+03
0.14758E+04 0.66454E+02 0.24304E+03
0.14907E+04 0.64530E+02 0.25400E+03
0.15055E+04 0.62676E+02 0.26517E+03
0.15204E+04 0.60999E+02 0.27663E+03
0.15354E+04 0.59429E+02 0.28833E+03
0.15500E+04 0.57764E+02 0.30002E+03
0.15641E+04 0.56109E+02 0.31144E+03
0.15758E+04 0.53850E+02 0.32117E+03
0.15882E+04 0.51118E+02 0.33162E+03
0.16010E+04 0.48445E+02 0.34255E+03
0.16127E+04 0.45813E+02 0.35263E+03
0.16249E+04 0.43266E+02 0.36339E+03
0.16373E+04 0.40811E+02 0.37449E+03
0.16498E+04 0.38485E+02 0.38581E+03
0.16620E+04 0.36479E+02 0.39707E+03
0.16742E+04 0.34549E+02 0.40846E+03
0.16860E+04 0.32632E+02 0.41963E+03
It would be complicated to limit the point reduction to a certain region, but you can do it globally using the pointinterval property of the style with linespoints. If you want to hide the line you can set the linetype to "nodraw": with linespoints lt nodraw pi 5. But that would get you back to the same result as using every to filter the points. The nice thing about using pointinterval instead is that the line goes through all the points even though not all of them are shown. So a jog in the line can highlight an outlier that might otherwise be hidden.
#Plot every 5th point
splot 'DATA' with linespoints pointinterval 5
I would say whether your data points look cluttered or cramped does not only depend on your data but also on your viewpoint.
If you have so many data points why don't you simply plot it with lines? Or as Ethan suggested with linespoints and a certain pointinterval or pointnumber (check help lp).
Script:
set multiplot layout 2,1
set view 60,30
splot $Data u 1:2:3 w p pt 1
set view 71,333
splot $Data u 1:2:3 w p pt 1
unset multiplot
Result: (same datapoints just different viewing angles)

Gnuplot seems to fail in linear fit

I have a problem with gnuplot.In my data there is a very obvious linear relation in a specific range. So I want to do a linear fit in that range. But gnuplot throws something like an orthogonal (to as it should be) out.
I created the following fitting-file:
set fit errorvariables
f(x)=a*x+b
fit f(x) 'Data1f.txt' using 1:2:3:4 xyerrors via a,b
g(x)=c*x+d
fit g(x) 'Data2f.txt' using 1:2:3:4 xyerrors via c,d
set xlabel 'U_G [V]'
set ylabel '{/Symbol=\326}(U_{Ph}-U_0) [{/Symbol=\326}U]'
set xrange [0:0.9]
set yrange [0:4.5]
set grid
plot 'Data1.txt' using 1:2:3:4 w xyerrorbars title 'Measurement 1', f(x) title 'f(x)', 'Data2.txt' using 1:2:3:4 w xyerrorbars title 'Masurement 2', g(x) title 'g(x)'
And it results in the following plot:
I don't know why it is not fitting the obviously linear part of the Data ('Data1f' and 'Data2f' contain exact the same values like 'Data1' and 'Data2' just with some data-points left out. (i tried that when the range comands 'fit [number:number] f(x)......' showed the same result.).
Even LibreOffice Calc was able to give me a fitting curve that resulted in the expected one (but LibreOffice Calc can't handle errors - only the data-points itself).
Because you specified the range after fitting, gnuplot fits the linear function to the full data set, which you said is non-linear. Therefore the result is obviously bad. If you change the order of your commands, fit will only use in-range data and you should get a reasonable fit:
set xrange [0:0.9]
set yrange [0:4.5]
fit f(x) 'Data1f.txt' using 1:2:3:4 xyerrors via a,b
fit g(x) 'Data2f.txt' using 1:2:3:4 xyerrors via c,d
You initialize a,b,c, and d with some value nearby that you are expecting. Then try it, it will work. Initially, the value may be some random garbage number and I could fix the same problem by Initializing the constants with some expected nearby values

Incorrect position and size of percentages in Gnu Plot

I have developped a CGI in bash/html that allow me to generate a graph of my clusters.
Here is an exemple :
This is a graph that works well. The problem is that for some graphs, the percentages overlap or shift far too far from where it should be. Here is my GNUPLOT code:
f(w) = (strlen(w) > 10 ? word(w, 1) . "\n" . word(w, 2) : w)
set title "TITLE"
set terminal png truecolor size 960, 720 background rgb "#eff1f0"
set output "/var/www/html/CLUSTER_NAME.png"
set bmargin at screen 0.1
set key top center
set grid
set style data histograms
set style fill solid 1.00 border -1
set boxwidth 0.7 relative
set yrange [*:*]
set format y "%g%%"
set datafile separator ","
plot 'test1.txt' using 2:xtic(f(stringcolumn(1))) title " CPU consumption (%) ", \
'' using 3 title " RAM consumption (%)", \
'' using 0:($2+1):(sprintf(" %g%%",$2)) with labels notitle, \
'' using 0:($3+1):(sprintf(" %g%%",$3)) with labels notitle
Here is an example of a graph that does not work properly because the percentages are too shifted :
I am able to change this by changing this line in my code:
'' using 0:($3+1):(sprintf(" %g%%",$3)) with labels notitle
To :
'' using 0:($3+1):(sprintf(" %g%%",$3)) with labels notitle
Adding spaces allows to shift the percentages :
But even if it works for this graph, it moves the percentages for the other graphs too... :
I can't get "clean" graphics. Either the percentages overlap, or they go out of scope because the values are too large, or they are completely shifted....
Another example:
Is there a way to make all this move by itself, automatically, according to the values and therefore the size of the bars etc?
You might try an alternative mechanism, using plot for [i=2:3] ... to loop through the 2 columns of values. Instead of guessing the number of spaces to indent, you estimate the x position of the bar using column(0)+(i-2)*.25 (for i = 2 then 3),
which I got to by trial and error.
For example, using a function mytitle to get the 2 titles (my gnuplot is too old for an array):
mytitle(x) = (x==2?"cpu":"ram")
plot for [i=2:3] 'data' using i:xtic(stringcolumn(1)) title mytitle(i), \
for [i=2:3] '' using (column(0)+(i-2)*.25):(column(i)+1):\
(sprintf("%g%%",column(i))) with labels notitle

Insertion of Greek letters in a graph legend using GNUplot

I am trying to incorporate greek symbols into my graph using following code, but keep getting similar error twice.
warning: enhanced text mode parser - ignoring spurious }
warning: enhanced text mode parser - ignoring spurious }
reset
# svg
#set terminal svg size 410,250 fname "Times New Roman" \
set terminal svg size 410,250, enhanced fname 'Times New Roman' \
fsize "12" rounded dashed
set output "data1.svg"
set tics nomirror
# color definitions
set style line 1 lc rgb "#8b1a0e" pt 1 ps 1 lt 1 lw 2 # --- red
set style line 2 lc rgb "#5e9c36" pt 2 ps 1 lt 2 lw 2 # --- green
set key bottom right
plot "abc.htm" using 1:2 title "N('\alpha', T)" w lp ls 1, \
"abc.htm" using 1:3 title "N(\beta, T)" w lp ls 5
PS: The code was running fine until I enabled enhanced mode of svg terminal, as I needed it for inserting greek letters in my graph legends. I am using version 4.6, patch level 5. Can any one help me out?
The correct way is to
use enhanced option of the terminal (you did)
wite {/Symbol a} for an alpha.
Search for symbols + gnuplot on the web, you'll find lists like http://mathewpeet.org/lists/symbols/ with codes understood by gnuplot!
Use a proper encoding (UTF-8) and insert the characters directly:
reset
set encoding utf8
set terminal svg size 410,250 enhanced fname 'Times New Roman' fsize "12" rounded dashed standalone
set output "data1.svg"
set linetype 1 lc rgb "#8b1a0e" lw 2
set linetype 2 lc rgb "#5e9c36" lw 2
set key bottom right
set style function linespoints
set samples 11
plot x title "N(α, T)", 2*x title "N(β, T)"
choose font 'Symbol'
choose corresponding English alphabet for Greek letter, eg. i have chosen 'c' for 'chi', below is the link for other characters.
http://folk.uio.no/hpl/scripting/doc/gnuplot/Kawano/label-e.html
fontsize can be changed easily.
eg...
set ylabel "c" font "Symbol,14"
will produce greek letter 'Chi'.
I have found the way to solve this problem. The Greek letters can be inserted in SVG file using following path in the Inkscape:
Go to Text drop down menu and then click on Glyphs. Next, select font family such as Times New Roman. After that select Greek from script and all from Range options, respectively. Then Greek letters could easily be inserted in the Graph.

clear differentiation of throughputs in gnuplot

I'm comparing the throughput of wireless link in two situations, i want to plot them both in a single graph. the problem is that the graph obtained by plotting throughput against time is as in this picture
when i plot both throughputs in the same graph i obtain something as in this second picture it is not clear to differentiate between the two.
I've used this code below for plotting a single throughput graph
#!/usr/bin/gnuplot
reset
!iperf -c 192.168.1.101 -i 0.5 -t 60 > a
#this is used for deleting first 6 lines
!sed -i 1,+5d a
#used to delete last line
!sed '$d' a > cropped
!cat cropped | cut -c 7-10 > b
!cat cropped | cut -c 35-38 > c
!paste b c > d
!awk 'BEGIN{print "0.0 0.0"}{print}' d > e
set xlabel "time"
set ylabel "throughput"
set terminal png nocrop enhanced font arial 8 size 900,300
#set terminal png size 900, 300
set output "chart_1.png"
#table name below graph(naming curve by colour)
set key below
plot 'e' using 1:2 title "Throughput Performance" with lines
below is the code which i have used for plotting both graphs
#!/usr/bin/gnuplot
reset
set xlabel "time"
set ylabel "throughput"
set terminal png nocrop enhanced font arial 8 size 900,300
#set terminal png size 900, 300
set output "chart_1.png"
#table name below graph(naming curve by colour)
set key below
set style data linespoints
plot "1" using 1:2 title "case1", \
"2" using 1:2 title "case2"
output looks like this:
As a general remark first: Use the pngcairo terminal which provides much better antialiasing.
For processing of your data you can use different smoothing options, like smooth csplines, smooth bezier or similar (see e.g. help smooth in the interactive gnuplot terminal):
plot "1" using 1:2 smooth csplines, "2" using 1:2 smooth csplines
Which smoothing variant you use depend again on the meaning of your data.
What could also help, is to use other point types then the default ones, e.g. pt 1 for the first and pt 7 for the second one, see Gnuplot line types for the use of the test command to check the available point types.

Resources