Graphics, Figures & TablesInvoke Gnuplot by the Compiler

Information and discussion about graphics, figures & tables in LaTeX documents.
ditka
Posts: 85
Joined: Fri Jul 13, 2012 11:59 am

Invoke Gnuplot by the Compiler

Post by ditka »

I would like to know, is it possible to call Gnuplot form LaTeX to create any sorts of plots that Gnuplot can do (polar coordinates, 3D,...)?

Thanx for answers.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Invoke Gnuplot by the Compiler

Post by localghost »

Yes, it is.


Thorsten
ditka
Posts: 85
Joined: Fri Jul 13, 2012 11:59 am

Re: Invoke Gnuplot by the Compiler

Post by ditka »

Coud you please tell me how, or show any links?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Invoke Gnuplot by the Compiler

Post by localghost »

Package gnuplottex. Links to possible solutions by Forum Search.
ditka
Posts: 85
Joined: Fri Jul 13, 2012 11:59 am

Invoke Gnuplot by the Compiler

Post by ditka »

I have tried both

Code: Select all

\begin{gnuplot}
plot sin(x)
\end{gnuplot}
and

Code: Select all

\begin{gnuplot}[terminal=hterminali]
plot sin(x)
\end{gnuplot}
I did not even get picture.

Perhaps I shoud point out that, what I mean was to use gnuplot in a way like this:

Code: Select all

\usepackage[latin1]{inputenc}
\usepackage{tikz}


\begin{tikzpicture}[domain=0:4]
    \draw[color=blue] plot[id=sin] function{sin(x)} 
\end{tikzpicture}
What shoud I do to use polar equation instead for example(I dinnt find any example in gnuplottex documentaion or on forum)?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Invoke Gnuplot by the Compiler

Post by localghost »

The pgfplots package can do that for you. And Section 5.7 of its manual shows you exactly how to do it.

Code: Select all

\documentclass[11pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}

\pagestyle{empty}

\begin{document}
  \begin{tikzpicture}
    \begin{polaraxis}
      \addplot+[mark=none,domain=0:360,samples=100]{sin(x)};
    \end{polaraxis}
  \end{tikzpicture}
\end{document}
Attachments
The resulting output.
The resulting output.
pgfplots-sin-polar.png (24.48 KiB) Viewed 5787 times
feuersaenger
Posts: 34
Joined: Sun Oct 16, 2011 5:56 pm

Re: Invoke Gnuplot by the Compiler

Post by feuersaenger »

Hi ditka,

If you follow along the suggestion of localghost and consider using pgfplots, you might not need gnuplot at all.

In fact, pgfplots can do polar axes, function sampling, 3D plots (line, scatter, mesh, surface, patch, quiver, and some more) without ever calling gnuplot (as in the example of localghost). Consequently, you do not need to have gnuplot available for pgfplots. It can call gnuplot to sample functions, although it does a quite good job of sampling functions on its own. The only exception is 3d contour plots: pgfplots cannot compute contour lines on its own and will call gnuplot for intermediate results. It will generate contour plots on its own, however.

If you want to find out if that is suitable for your needs, you may want to browse through the many examples of the pgfplots manual on http://pgfplots.sourceforge.net/ . We can certainly help you if you run into problems with some specific example of using pgfplots.

Best regards

Christian
ditka
Posts: 85
Joined: Fri Jul 13, 2012 11:59 am

Re: Invoke Gnuplot by the Compiler

Post by ditka »

Pgf plots is apparenty quite powerful , but what bother me is that I can not manipulate with coodinate axis(add labels x,y,colour, lenght of both axes,...) and with coordinate system.

And is it possibly to draw the picture os that you post it(sin(x)) without any circles(except one that is graph of curve), in "normal" coordinate system?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Invoke Gnuplot by the Compiler

Post by localghost »

ditka wrote:Pgf plots is apparenty quite powerful , but what bother me is that I can not manipulate with coodinate axis(add labels x,y,colour, lenght of both axes,...) and with coordinate system. […]
Actually the package manual shows very clearly how to set up plots.
ditka wrote:[…] And is it possibly to draw the picture os that you post it(sin(x)) without any circles(except one that is graph of curve), in "normal" coordinate system?
A polar plot in Cartesian coordinates makes no sense. Correct me when I'm wrong, but you explicitly asked for polar plots.
ditka wrote:I would like to know, is it possible to call Gnuplot form LaTeX to create any sorts of plots that Gnuplot can do (polar coordinates, 3D,...) […]
So you better clarify what you really want. If you want a sine curve in Cartesian coordinates (wave), then you should read Section 19.5 of the excellent pgf/tikZ manual to learn more about that.

Code: Select all

\documentclass[11pt]{article}
\usepackage{tikz}

\begin{document}
  \begin{tikzpicture}[domain=0:6.28]
    \draw[color=blue] plot (\x,{sin(\x r)});
  \end{tikzpicture}
\end{document}
If you can't explain what you want, do a sketch and upload the picture to the forum server as attachment to your next post. At the moment I don't understand what you are after.
ditka
Posts: 85
Joined: Fri Jul 13, 2012 11:59 am

Re: Invoke Gnuplot by the Compiler

Post by ditka »

Well, what I want in the first place is to know how to call gnuplot for other options, rather then simple plots(polar,paramteric,...). Than you said that this can be done without gnuplot, but it semems using pgfplots there are some limitations also.

Nevertheless, the basic idea was, how to call gnuplot, for other functions, rahter than simle ones like type f(x)= something, sice, like I alredy mentioned gnuplot on its own can plot a lot things.
Post Reply