I think the trim right
and trim left
options are only useful if there is something which sticks out of the axis' box -- for example, if you want to exclude a legend from the horizontal alignment.
In your case, it appears to me that it suffices to surround the table and the graphics with
\begin{flushright}
...
\end{flushright}
If you have multiple elements which you want to align, you can also pack all of them into a tabular (which supports left-aligned or right-aligned columns in a natural way).
Once you start with horizontal and vertical alignment, you should consider using the \begin{tikzpicture}[baseline]
option and the \begin{tabular}[c]
flag as well -- both are part of the associated control mechanisms (which are explained in more detail in the pgfplots manual, there is a section "Alignment" somewhere which should also cover these specific cases).
Version 1.10 of pgfplots has been released just recently, and it comes with a new solution for the problem to fill the area between plots.
For your simple case, the answer of percusse is the way to go.
However, for anything which is slightly more complex, the following approach might be good to know: it allows to fill the area between any two plots by means of the fillbetween
library. In order to keep the knowledge base of this site up-to-date, I present a solution based on the new fillbetween
library here:
![enter image description here](https://i.stack.imgur.com/blpSl.png)
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot[name path=f, fill=red, fill opacity=0.5, thick, mark=none]
coordinates {
(1, 40)
(10, 400)
(100, 4000)
(150, 6000)
(200, 8000)
(250, 10000)
(300, 12000)
(350, 14000)
(500, 20000)
(750, 30000)
(1000, 40000)
};
\path[name path=axis] (axis cs:0,40000) -- (axis cs:1000,40000);
\addplot[gray!50] fill between[of=f and axis];
\end{axis}
\end{tikzpicture}
\end{document}
This solution relies on \usepgfplotslibrary{fillbetween}
: it assigns name path=f
to the function of interest. Then, it generates an artificial \path
which is neither drawn nor filled: this path is at y=40000
. Finally, it fills the area between f and axis
by means of \addplot fill between
.
Best Answer
If you're not stuck to
pgfplots
,pst-plot
has a\psVectorfield
command which makes it very easy (adapted from an example in the pst-plot documentation):