This question led to a new package:
tikzscale
When I try to scale a plot with: width=\textwidth there is some horizontal space between the
start/end of the plot and the start/end of the margins, see this example:
\documentclass[10pt,a4paper]{report}
\usepackage[latin1]{inputenc}
\usepackage{palatino}
\usepackage{color}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}
\pgfplotsset{compat=1.3}
\begin{document}
\setlength{\parindent}{0ex}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\vspace*{2ex}
\begin{tikzpicture}
\begin{axis}[
height=5cm,
width=\textwidth,
grid=both,
minor x tick num=4,
minor y tick num=4,
major tick length=0.15cm,
minor tick length=0.075cm,
tick style={semithick,color=black},
date coordinates in=x,
xticklabel=\day.\month.,
date ZERO=2009-09-02,% <- improves precision!
]
\addplot[color = black, mark=diamond*] coordinates {
(2009-08-07, 98)
(2009-08-09, 92)
(2009-08-12, 94)
(2009-08-15, 87)
(2009-08-19, 82)
(2009-08-26, 65)
(2009-08-29, 54)
(2009-09-02, 31)
};
\end{axis}
\end{tikzpicture}
\vspace*{2ex}Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{document}




\includegraphics[width=\textwidth]{fileContainingTikzpicture}. – Patrick Häcker Oct 31 '12 at 14:33tikzscalein my answer to http://tex.stackexchange.com/questions/89899/tikzpicture-in-minipage, because that's when I realised just how useful your approach actually is. It's great that you made that package available, it'll definitely come in handy. – Jake Jan 22 '13 at 06:53axisenvironments in onetikzpictureenvironment? For instance, in case of twoaxisenvironments next to each other. See also http://tex.stackexchange.com/questions/270687/error-tikzscale-package-when-scaling-a-figure-containing-two-axis-environment – Adriaan Oct 06 '15 at 13:35tikzscalepackage, can you make the following effect? Generate the corresponding PDF file for the first time compiling the tikz file. This could save compiling time if there is already a compiled pdf file there, instead of running the tikz file on every compiling routine. Thanks. – Xiaodong Qi Mar 15 '18 at 03:32