![如何在 pgfplots 中对不同的等值线使用相同的线型](https://linux22.com/image/275770/%E5%A6%82%E4%BD%95%E5%9C%A8%20pgfplots%20%E4%B8%AD%E5%AF%B9%E4%B8%8D%E5%90%8C%E7%9A%84%E7%AD%89%E5%80%BC%E7%BA%BF%E4%BD%BF%E7%94%A8%E7%9B%B8%E5%90%8C%E7%9A%84%E7%BA%BF%E5%9E%8B.png)
我需要帮助,如何在三元图中使用相同的线型,而不需要使用不同的颜色、线型和图例。下面的程序给出了一个示例,它给出了三种颜色和三种线型的结果。我希望删除图例、等值线中的颜色,并对 0.9、0.8 和 0.7 等值线处的三个绘制坐标使用相同的线型。谢谢。
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepgfplotslibrary{ternary}
\begin{document}
\begin{tikzpicture}
\begin{ternaryaxis}[
ternary limits relative=false,
width=7.5cm,
height=7.5cm,
ymax=1.0,
clip=false,
disabledatascaling,
minor tick num=1,
grid=both,
% xlabel=A,
% ylabel=B,
% zlabel=C,
]
\addplot3 coordinates {
(0.9047, 0.0953, 0.0000)
(0.9019, 0.0883, 0.0098)
(0.8993, 0.0806, 0.0201)
(0.8969, 0.0722, 0.0309)
(0.8950, 0.0630, 0.0420)
(0.8936, 0.0532, 0.0532)
(0.8929, 0.0428, 0.0643)
(0.8930, 0.0321, 0.0749)
(0.8938, 0.0212, 0.0850)
(0.8953, 0.0105, 0.0942)
(0.8975, 0.0000, 0.1025)
};
\addplot3 coordinates {
(0.8209, 0.1791, 0.0000)
(0.8131, 0.1682, 0.0187)
(0.8054, 0.1557, 0.0389)
(0.7980, 0.1414, 0.0606)
(0.7913, 0.1252, 0.0835)
(0.7859, 0.1071, 0.1071)
(0.7823, 0.0871, 0.1306)
(0.7810, 0.0657, 0.1533)
(0.7822, 0.0436, 0.1742)
(0.7859, 0.0214, 0.1927)
(0.7917, 0.0000, 0.2083)
};
\addplot3 coordinates {
(0.7439, 0.2561, 0.0000)
(0.7313, 0.2418, 0.0269)
(0.7186, 0.2251, 0.0563)
(0.7060, 0.2058, 0.0882)
(0.6942, 0.1835, 0.1223)
(0.6841, 0.1580, 0.1580)
(0.6767, 0.1293, 0.1940)
(0.6729, 0.0981, 0.2290)
(0.6734, 0.0653, 0.2613)
(0.6777, 0.0322, 0.2901)
(0.6848, 0.0000, 0.3152)
};
\node[fill=white,draw] at (0.5,{sqrt(3)/2}) {$Sn$};
\node[fill=white,draw] at (0,0) {$Sb$};
\node[fill=white,draw] at (1,0) {$Bi$};
\legend{0.9, 0.8,0.7}
\end{ternaryaxis}
\end{tikzpicture}
\end{document}
答案1
要对所有轮廓线使用相同的线条样式,请使用\addplot [black] ...
而不是\addplot
。要删除标记,请使用no markers
。要删除图例,请删除以下\legend{...
行:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepgfplotslibrary{ternary}
\begin{document}
\begin{tikzpicture}
\begin{ternaryaxis}[
ternary limits relative=false,
width=7.5cm,
height=7.5cm,
ymax=1.0,
minor tick num=1,
grid=both,
no markers,
xlabel=Sn,
xlabel style={
at={(axis cs:1,0,0)},
anchor=south
},
ylabel=Sb,
ylabel style={
at={(axis cs:0,1,0)},
anchor=10
},
zlabel=Bi,
zlabel style={
at={(axis cs:0,0,1)},
anchor=north west
},
]
\addplot3 [black, dashed] coordinates {
(0.9047, 0.0953, 0.0000)
(0.9019, 0.0883, 0.0098)
(0.8993, 0.0806, 0.0201)
(0.8969, 0.0722, 0.0309)
(0.8950, 0.0630, 0.0420)
(0.8936, 0.0532, 0.0532)
(0.8929, 0.0428, 0.0643)
(0.8930, 0.0321, 0.0749)
(0.8938, 0.0212, 0.0850)
(0.8953, 0.0105, 0.0942)
(0.8975, 0.0000, 0.1025)
};
\addplot3 [black, dashed] coordinates {
(0.8209, 0.1791, 0.0000)
(0.8131, 0.1682, 0.0187)
(0.8054, 0.1557, 0.0389)
(0.7980, 0.1414, 0.0606)
(0.7913, 0.1252, 0.0835)
(0.7859, 0.1071, 0.1071)
(0.7823, 0.0871, 0.1306)
(0.7810, 0.0657, 0.1533)
(0.7822, 0.0436, 0.1742)
(0.7859, 0.0214, 0.1927)
(0.7917, 0.0000, 0.2083)
};
\addplot3 [black, dashed] coordinates {
(0.7439, 0.2561, 0.0000)
(0.7313, 0.2418, 0.0269)
(0.7186, 0.2251, 0.0563)
(0.7060, 0.2058, 0.0882)
(0.6942, 0.1835, 0.1223)
(0.6841, 0.1580, 0.1580)
(0.6767, 0.1293, 0.1940)
(0.6729, 0.0981, 0.2290)
(0.6734, 0.0653, 0.2613)
(0.6777, 0.0322, 0.2901)
(0.6848, 0.0000, 0.3152)
};
\end{ternaryaxis}
\end{tikzpicture}
\end{document}