3

I'm using fixed axes. pgfplots with gnuplots doesn't draw the line of the graph when I specify these axis dimensions:

\begin{tikzpicture}
    \begin{axis}[ height=6cm, width=6cm,
        xmin=8, xmax=12,
        ymin=800,   ymax=1500]
\addplot gnuplot {10517/x};
\end{axis}
\end{tikzpicture}

The output I get is simply the axes with no graphed line. For example, (9,1168.5) is a point on the line, so it should be visible here. Any suggestions? I'm using TeXworks as the editor.

Thank you.

Torbjørn T.
  • 206,688
  • Did you compile with --shell-escape enabled? (http://tex.stackexchange.com/a/82710/586) Edit: also, the default domain is -5:5 I believe, so any points will be outside the axis limits you've set. – Torbjørn T. Jan 09 '17 at 12:57
  • Thank you! I didn't know about the default domain. – Rebecca Schley Jan 09 '17 at 13:04
  • It's the default for pgfplots at least, on second thought I'm not entirely sure what happens when gnuplot is used like this. – Torbjørn T. Jan 09 '17 at 13:06

1 Answers1

4

You have to set up the domain as an optional argument of gnuplot:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[ height=6cm, width=6cm,
        xmin=8, xmax=12,
        ymin=800,   ymax=1500]
\addplot gnuplot [domain=8:12] {10517/x};
\end{axis}
\end{tikzpicture}
\end{document}

result

Schweinebacke
  • 26,336
  • @RebeccaSchley feel free to mark this answer as 'accepted' using the Green tick -- this rewards Schweinebacke with a further 15 reputation points for their time :) – cmhughes Jan 09 '17 at 16:19