0

using width and height I can make the graph bigger, however if it is made too big the graph will start to shift towards the right and bottem of the page, despite there being plenty of space left on the page up in the top and left of the page. How can I force the graph to always remain in the center (both vertically and horizontally) of the page and not shift itself when its made bigger.

    \begin{tikzpicture}[rotate=90]
    \begin{axis}
    [
        width=24cm, height=17cm,
        title={},
        xlabel={},
        ylabel={},
        minor grid style = dashed,
        major grid style = draw,
        minor tick num = 1,
        grid = both,
        mark size = 1,
    ]
    \addplot[scatter,mark=square*,mark size=2,only marks]
        table{data.dat};
    \addplot[thick,red]
        table[y={create col/linear regression={y=Y}}]{data.dat};
    \end{axis}
\end{tikzpicture}

enter image description here

Vent
  • 35
  • Have you wrapped the tikzpicture inside \begin{center} ... \end{center}? – alexkelbo Mar 12 '16 at 14:44
  • Yes, it doesent seem to do anything. – Vent Mar 12 '16 at 14:48
  • Related: http://tex.stackexchange.com/questions/46903/ and http://tex.stackexchange.com/questions/2651/ and especially http://tex.stackexchange.com/questions/28067 ([p] float placement ). By the way without your data files we cannot work with your code. And we need a full compilable code with documentclass, (minimal set of) packages and so on (called MWE: Minimal Working Example) – Dr. Manuel Kuehner Mar 12 '16 at 14:49
  • Did you try my advice? – Dr. Manuel Kuehner Mar 16 '16 at 22:23

1 Answers1

1

An A4 paper page is about 21cm x 29.7cm, you're setting your graph at 17cm x 24cm. This means that you have an extra 4cm in height and 5.7cm in width to play with. Add the fact that you could have margins, and you don't have much left. At that point, you don't have really much for positioning.

The shifting is a result of your huge graph, when compared to the page, conflicting with the margins.

So your solution would be: either reduce your margins, or — in my opinion the best solution — reduce the size of the graph.

You can place your graph without additional packages like this:

\documentclass[a4paper]{article}
\usepackage{pgfplots}

\pgfplotsset{compat=1.13}

\begin{document}
\begin{figure}[!htb]
\centering
\begin{tikzpicture}

    ...

\end{tikzpicture}
\end{figure}
\end{document} 

This is a minimal example. If you have margins like

\usepackage[<margins>]{geometry}

then you can set an exception for this page, assuming the printer can print that far, by saying

\newgeometry{margin=2cm}
<graph>
\restoregeometry

So that the margins for only that page will be 2cm on all sides.

Alenanno
  • 37,338