我希望两个红色函数之间有一个菱形图案(或另一个图案)。此外,如果$H_{S_2}(\beta)$
在它的左侧显示虚线样式(就像在图例中通常所做的那样),那就太好了。在左侧应显示相同的图例样式标识(即包含的图案)$W_{S_1}(\beta)$
。
\documentclass[11pt,fleqn,numbers=noenddot]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{pgfplots,pgfplotstable}
\usepackage[locale=DE]{siunitx}
\usepackage{pdflscape}
\usepackage{nicefrac}
\pgfplotsset{
compat=newest,
xlabel near ticks,
ylabel near ticks,
myplot/.style={smooth,tension=0.5,mark=none,very thick}
}
\begin{document}
\begin{landscape}
\begin{tikzpicture}
\begin{axis}[
width=1.5\textwidth,height=0.9\textheight,
axis x line=bottom,
xmin=0,
xmax=1,
xtick={0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1},
axis y line=left,
ymin=70,
ymax=120,
ytick={75,85,95,105,115},
ylabel={$w$},
xlabel={$\beta$},
%grid=major,
legend style={
at={(current bounding box.north-|current axis.east)},
anchor=east,
legend columns=2
}
]
%W_1 upper
\addplot+[color=red,dotted,myplot ]
coordinates {
(0, 100.3)
(0.1, 98)
(0.2, 95.5)
(0.3, 92.7)
(0.4, 89.7)
(0.5, 86.4)
(0.6, 82.7)
(0.67, 80)
}
;
\addplot[red,domain=0:0.67]{80};
\node at (0.2,90) { \textcolor{red}{$W_{S_1}(\beta)$}};
\node at (0.2,100) { $H_{S_2}(\beta)$};
\end{axis}
\end{tikzpicture}
\end{landscape}
\end{document}
我怎样才能做到这一点?
答案1
使用fillbetween
和patterns
库:
\documentclass[11pt,fleqn,numbers=noenddot]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{pgfplots,pgfplotstable}
\usepackage[locale=DE]{siunitx}
\usepackage{pdflscape}
\usepackage{nicefrac}
\pgfplotsset{
compat=newest,
xlabel near ticks,
ylabel near ticks,
myplot/.style={smooth,tension=0.5,mark=none,very thick}
}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}
\begin{document}
\begin{landscape}
\begin{tikzpicture}
\begin{axis}[
width=1.5\textwidth,height=0.9\textheight,
axis x line=bottom,
xmin=0,
xmax=1,
xtick={0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1},
axis y line=left,
ymin=70,
ymax=120,
ytick={75,85,95,105,115},
ylabel={$w$},
xlabel={$\beta$},
%grid=major,
legend style={
at={(current bounding box.north-|current axis.east)},
anchor=east,
legend columns=2
}
]
%W_1 upper
\addplot+[color=red,dotted,myplot,name path=A]
coordinates {
(0, 100.3)
(0.1, 98)
(0.2, 95.5)
(0.3, 92.7)
(0.4, 89.7)
(0.5, 86.4)
(0.6, 82.7)
(0.67, 80)
}
;
\addplot[red,domain=0:0.67,name path=B]{80};
\addplot[pattern=crosshatch dots,pattern color=red] fill between[of=A and B];
\node at (0.2,90) { \textcolor{red}{$W_{S_1}(\beta)$}};
\node at (0.2,100) { $H_{S_2}(\beta)$};
\end{axis}
\end{tikzpicture}
\end{landscape}
\end{document}