![如何在使用 TikZ 的 \datavisualization … info[options]{code} …; 命令强调几个点时减少代码?](https://linux22.com/image/356043/%E5%A6%82%E4%BD%95%E5%9C%A8%E4%BD%BF%E7%94%A8%20TikZ%20%E7%9A%84%20%5Cdatavisualization%20%E2%80%A6%20info%5Boptions%5D%7Bcode%7D%20%E2%80%A6%3B%20%E5%91%BD%E4%BB%A4%E5%BC%BA%E8%B0%83%E5%87%A0%E4%B8%AA%E7%82%B9%E6%97%B6%E5%87%8F%E5%B0%91%E4%BB%A3%E7%A0%81%EF%BC%9F.png)
这个问题一直困扰着我其他。
查看代码:
\documentclass{scrartcl}
\usepackage{tikz}
\usepackage[per-mode = fraction]{siunitx}
\usetikzlibrary{datavisualization.formats.functions}
\begin{document}
\begin{tikzpicture}
\datavisualization[scientific axes = {clean,
end labels
},
x axis = {label = $\frac{v}{\si{\cubic\m\per\kg}}$},
y axis = {label = $\frac{p}{\si{\bar}}$},
data/format = function,
visualize as smooth line/.list = {isentropic_press,
isobaric,
isentropic_decompress
}
]
data[set = isentropic_press] {var x : interval[.5 : 2];
func y = 1 / \value x ^ 1.4;
}
data[set = isobaric] {var x : interval[.5 : 1];
func y = 1 / .5 ^ 1.4;
}
data[set = isentropic_decompress] {var x : interval[1 : 2];
func y = 1 / (\value x - .5) ^ 1.4;%-.5: shifts the function by - 0.5 to the right
}
%accents important points
info {\draw (visualization cs:x = 2,
y = {(1 / 2 ^ 1.4)}
) circle [radius = 1pt]
node [right,
font = \footnotesize
] {1};
}
info {\draw (visualization cs:x = .5,
y = {(1 / .5 ^ 1.4)}
) circle [radius = 1pt]
node [above,
font = \footnotesize
] {2};
}
info {\draw (visualization cs:x = 1,
y = {(1 / .5 ^ 1.4)}
) circle [radius = 1pt]
node [above,
font = \footnotesize
] {3};
}
info {\draw (visualization cs:x = 2,
y = {(1 / 1.5 ^ 1.4)}
) circle [radius = 1pt]
node [right,
font = \footnotesize
] {4};
};
\end{tikzpicture}
\end{document}
上面的行info
(以注释开头%accents important points
)看起来已经相同了(只有坐标、对齐和文本发生了变化)。有没有办法在强调多个点时减少代码量?
该\datavisualization ... info[options]{code} ...;
命令在TikZ & PGF
手动的。
提前谢谢你的帮助!
答案1
没有太多需要缩短的内容。你可以将它们全部放入一个info
组中,例如
\begin{tikzpicture}[change/.style={font=\footnotesize}]
[…]
info {\draw (visualization cs: x = 2, y= {(1/2^1.4)}) circle [radius = 1pt] node [right, change] {1}
(visualization cs: x = .5, y= {(1/.5^1.4)}) circle [radius = 1pt] node[above, change] {2}
(visualization cs: x = 1, y= {(1/.5^1.4)}) circle [radius = 1pt] node[above, change] {3}
(visualization cs: x = 2, y= {(1/1.5^1.4)}) circle [radius = 1pt] node[right, change] {4}
;};
\end{tikzpicture}
我没能把它放到列表中;但话说回来,它只有四个点。您也可以将节点标记为node(A){}
并在环境之外引用它们\datavisualization
,以便对它正在做的事情有一点控制。据我所知,在里面没有“在第一个/最后一个数据点上放一些东西” \datavisualization
,这令人失望。在实现这一点之前,您必须手动处理兴趣点。毕竟,tikz
不知道哪些点是特殊的。