2

I am trying to insert gnuplot inside my IEEE Tran paper (Platform is Windows). I am unable to do it correctly. Here is the code. The below give code is not working. No output is obtained. I am writing all the packages just in case they are required.

Code 1

\documentclass[conference]{IEEEtran}

\ifCLASSINFOpdf

\else
\fi
\usepackage[usenames,dvipsnames]{color}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes.multipart}
\usepackage[caption=false]{subfig}
\usepackage{tabularx,tikz}
\usepackage{ifthen}

\usepackage[shell]{gnuplottex}
\hyphenation{op-tical net-works semi-conduc-tor}


\begin{document}

\title{Bare Demo of IEEEtran.cls for Conferences}

\maketitle

\IEEEpeerreviewmaketitle

\section{Introduction}
I wish you the best of success.

\begin{gnuplot}[terminal=pdf,terminaloptions={font ",10" linewidth 3}]
plot sin(x), cos(x)
\end{gnuplot}
\end{document}

I also used the below given code but the margins are way too wide for a conference. Please suggest solutions for it. I would be happy to get some feedback on how to use epslatex inside the latex. Kindly, advice me for IEEE Tran.

Code 2

gnuplot> set terminal latex
Terminal type set to 'latex'
Options are '(document specific font) norotate'
gnuplot> set output 'plot.tex'
gnuplot> plot x**2
gnuplot> unset output

Below given I wrote in a latex file :

\documentclass[conference]{IEEEtran}
\ifCLASSINFOpdf

\else
\fi
\usepackage[usenames,dvipsnames]{color}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes.multipart}
\usepackage[caption=false]{subfig}
\usepackage{tabularx,tikz}
\usepackage{ifthen}

\usepackage[shell]{gnuplottex}
\hyphenation{op-tical net-works semi-conduc-tor}


\begin{document}

\title{Bare Demo of IEEEtran.cls for Conferences}

\maketitle

\IEEEpeerreviewmaketitle

\section{Introduction}
I wish you the best of success.
\input{plot.tex}
\end{document}
  • Can't you use a figure* environment? – egreg Jun 30 '14 at 23:38
  • \begin{figure*} \input{plot.tex} \end{figure*} This is what I tried keeping everything else the same. Could you give me more input on how could I use figure* environment? I am a beginner here. – New User Jul 1 '14 at 0:15
  • I just did what you were saying it worked but the problem is my document has two columns and when I use figure* it takes space in both the columns and pushes the text downwards. Is there a way I can keep this plot only on one column? Please let me know. Thanks! – New User Jul 1 '14 at 3:05
  • I have found another bug here. The plot is completely black and white. I want it to be colored , I checked it somewhere else and I found that when we include plot.tex file inside figure* environment, the environment only gives black and white plots. How could I get colored plots? – New User Jul 1 '14 at 5:07
  • 1
    The gnuplot terminal pdf requires the color option for colored output – user31729 Jul 1 '14 at 5:46
1

The reason why your code doesn't work are the characters e.g. in ’$\cos(x)$’. Replace them with ' and you get the desired output (so e.g. ’$\cos(x)$’ --> '$\cos(x)$' )

Besides that, the code works for me:

enter image description here

I'll update the manual in the next days, as the characters are shown wrong there, thank you!

  • 1
    I would like to welcome to TeX-SX in case we didn't already :) – percusse Jul 4 '14 at 14:25
  • Thanks John. I am glad you answered my question. It did not work for me. I tried several other things but it seems like TexStudio is not working for me. The example you gave me seems to be correct as well. I think my settings are not correct for Texstudio. I need to search more on how to setup GnuPlot compilation inside the Tex files for TexStudio. – New User Jul 6 '14 at 22:16
  • @user56277 Could you attach your logfile? Maybe I can help then. – John Jul 7 '14 at 7:34
0

Here is a possible solution for the question but this produces only black and white plots. This is a disappointment. Could somebody tell me how to produce colored plots ? I would be grateful to the person. Thanks!

This is the code for gnuplot

gnuplot> set terminal latex                                                                       
Terminal type set to 'latex'
Options are '(document specific font) norotate'
gnuplot> set output "force.tex"
gnuplot> set size 0.65,0.85    
gnuplot> plot  'force.dat' using 1:2 title 'Column' with lines, "force.dat" u 1:3 t 'Beam' w lines
points

This is the code that I gave in the pdf file in Tex Studio .

\documentclass[conference]{IEEEtran}

\ifCLASSINFOpdf

\else
\fi

\usepackage[usenames,dvipsnames]{color}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes.multipart}
\usepackage[caption=false]{subfig}
\usepackage{tabularx,tikz}
\usepackage{ifthen}

\usepackage{amsmath}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}    
\usepackage{graphicx}
\usepackage{epstopdf}

\begin{document}

\title{Bare Demo of IEEEtran.cls for Conferences}

\maketitle

\IEEEpeerreviewmaketitle

\section{Introduction}
I wish you the best of success.

\begin{figure}[!ht]
\input{force.tex}
\end{figure}

\end{document}

This is the text file that I created

# This file is called   force.dat
# Force-Deflection data for a beam and a bar
# Deflection    Col-Force       Beam-Force 
0.000              0              0    
0.001            104             51
0.002            202            101
0.003            293            148
0.0031           294            148
0.004            282            204
0.0041           290            208
0.005            310            250
0.010            311            260
0.020            280            240
  • 2
    I would strongly recommend to use another terminal in gnuplot, as the latex terminal offers relatively bad output compared with other available terminals (e.g. cairolatex, epslatex and tikz). – John Jul 2 '14 at 16:40
0

This is not a solution but I tried below given code. This might act as a solution to some people out there. This is an example that I tried from the manual -

ftp://ftp.fu-berlin.de/tex/CTAN/macros/latex/contrib/gnuplottex/gnuplottex.pdf

Texstudio is not showing any errors but it is not plotting anything. I am not sure if I am making a mistake or not. I tried using cairolatex and epslatex. Here is the code. I have included all the packages that I included in my TexStudio. Texstudio just prints the caption in the pdf and nothing else.

\documentclass[conference]{IEEEtran}

\ifCLASSINFOpdf

\else
\fi

\usepackage[usenames,dvipsnames]{color}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes.multipart}
\usepackage[caption=false]{subfig}
\usepackage{tabularx,tikz}
\usepackage{ifthen}

\usepackage{amsmath}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
%\usepackage{color}
%\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[miktex]{gnuplottex}
%
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage{epstopdf}


\begin{document}

\title{Bare Demo of IEEEtran.cls for Conferences}

\maketitle

\IEEEpeerreviewmaketitle

\section{Introduction}
I wish you the best of success.
\begin{figure}%
\centering%
\begin{gnuplot}[terminal=cairolatex, terminaloptions=color dashed]
set key box top left
set key width 4
set key height 0.25
set key spacing 1.2
set key opaque
set sample 1000
set xr [-5:5]
set yr [-1:1]
set xlabel ’$x$-label’
set ylabel ’$y$-label’
plot sin(x) w l lc 1 lw 3 t ’$\sin(x)$’,\
cos(x) w l lc 7 lw 3 t ’$\cos(x)$’,\
tan(x) w l lc 3 lw 3 t ’$\tan(x)$’,\
tanh(x) w l lc 4 lw 3 t ’$\tanh(x)$’
\end{gnuplot}
\caption{This is a simple example using the cairolatex-terminal.}%
\label{pic:cairolatex}%
\end{figure}%

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.