我正在加载我的文件.tex
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
但我收到此错误:
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian)
restricted \write18 enabled.
entering extended mode
(./cappello.tex
LaTeX2e <2011/06/27>
Babel <3.9h> and hyphenation patterns for 78 languages loaded.
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.2 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
由于我没有 tlmgr - 顺便说一句:我在 Ubuntu 上 - 我尝试pgfplots
从这里
我通过终端进入文件夹/usr/share/texlive/texmf-dist/tex/latex
并pgfplots
发现里面有这些文件:
bugtracker.sty libs pgfplots.sty pgfplotstable.sty pgfregressiontest.sty
因此,我从下载的文件夹中ctan
复制并粘贴了这四个文件.sty
。我更新了它sudo texhash
,但仍然不起作用。我该如何解决?
编辑:如果我跑
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,italian]{babel}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis} [grid=major,width=12cm,ymin=0,ymax=42,ytick={0,5,10,...,40},
legend pos=outer north east,
xlabel={N\ped{fila fori}}, ylabel={Nu\ped{medio}}]
\addplot [black, line width=1pt, mark=none,smooth]
coordinates {
(1,28.2187430649)
(2,29.1498520781)
(3,30.1348567804)
};
\legend {Corr}
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
它有效,但我得到了
Package pgfplots notification 'compat/show suggested version=true': document has been generated with the most recent feature set (\pgfplotsset{compat=1.9}).
如果我跑
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\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)
};
\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}
它不起作用,我得到了
I can't find file `pgflibrarypgfplots.fillbetween.code.tex'.
<to be read again>
\relax
l.13 \usepgfplotslibrary{fillbetween}
(Press Enter to retry, or Control-D to exit)
Please type another input file name:
而如果我使用\pgfplotsset{compat=1.10}
10 或以上,它就不起作用了,我得到
Package pgfkeys Error: Choice '1.10' unknown in key '/pgfplots/compat/anchors
'. I am going to ignore this key.
See the pgfkeys package documentation for explanation.
Type H <return> for immediate help.
...
l.11 \pgfplotsset{compat=1.10}