
下面是一個最小的腳本範例,它從檔案中讀取數據,然後填充由 x 軸下方的繪圖和 x 軸本身定義的區域。輸入檔可以在這裡找到:
http://expirebox.com/download/0055b781a018392f326c55e6946707ca.html
問題是它在編譯時不顯示陰影,並且不傳回任何錯誤來表明存在問題。我使用 LuaLaTex,但嘗試過 XeLaTex 和 PDFLaTex,但都沒有顯示陰影。我定義路徑的方式有問題還是資料本身有問題?
\documentclass[preview=true]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}[baseline]
\begin{axis} [name=mainplot,clip mode=individual,
%width=\textwidth,
axis y line=left,
y axis line style=<->,
x axis line style=->,
xlabel={x},
ylabel={y},
xtick align=inside,
ytick align=inside,
axis x line=middle,
xmin=0,
xmax=8,
ymax=0.7,
ytick={-0.1,0,...,0.8},
ymin=-0.1,
minor y tick num =3,
minor x tick num =1,
restrict x to domain=/pgfplots/xmin:/pgfplots/xmax,
]
\addplot[name path=A,blue,thick] table[x=x,y=w] {input_file.txt};
\path[name path=B](\pgfkeysvalueof{/pgfplots/xmin},0)--(\pgfkeysvalueof{/pgfplots/xmax},0);
\addplot fill between[of=A and B,
split,
every segment no 1/.style=
{pattern=north east lines},
every segment no 2/.style=
{fill=none},
];
\end{axis}
\end{tikzpicture}
\end{document}
輸出如下圖所示;目標是對 x 軸下方並以繪圖為界的區域進行著色(即 0 -> ~3)。
提前謝謝了
雪人