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.

        width=24cm, height=17cm,
        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[y={create col/linear regression={y=Y}}]{data.dat};

enter image description here


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:






This is a minimal example. If you have margins like


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


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

  • Adjusting the size of the margins worked great, thanks! – Syne Mar 12 '16 at 18:10

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.