我使用下面的代码,我不明白为什么“水平线”比其他的更细。
\documentclass{article}
\usepackage{tikz,tikz-3dplot}
\usetikzlibrary{calc,arrows,positioning}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{tikzpicture}[scale=5,
vector/.style={thick,black,>=stealth,->},
atom/.style={blue}
]
\begin{axis}[
axis lines=none,
xmin=-0.1,
xmax=2.1,
ymin=-0.1,
ymax=2.1,
zmin=-0.1,
zmax=2.1,
% xtick=\empty,
% ytick=\empty,
% ztick=\empty
]
\coordinate (A0) at (axis cs:0,0,0);
\coordinate (A1) at (axis cs:0.2,0.5,0);
\coordinate (A2) at (axis cs:0.6,0.4,0);
\coordinate (A3) at (axis cs:0.8,0.9,0);
\coordinate (A4) at (axis cs:0.2,0,1);
\coordinate (A5) at (axis cs:0.4,0.5,1);
\coordinate (A6) at (axis cs:0.8,0.4,1);
\coordinate (A7) at (axis cs:1,0.9,1);
\draw[blue] (A0) -- (A1) -- (A5) -- (A4) -- cycle;
\draw[blue] (A2) -- (A3) -- (A7) -- (A6) -- cycle;
\draw[blue] (A0) -- (A1) -- (A3) -- (A2) -- cycle;
\draw[blue] (A4) -- (A5) -- (A7) -- (A6) -- cycle;
\draw[vector,red] (A0) -- (A4);
\end{axis}
\end{tikzpicture}
\end{document}
答案1
代码中的行
vector/.style={thick,black,>=stealth,->},
仅有的定义vector
包含选项的样式。thick
这只是样式的定义vector
,并不适用于任何地方。红线由
\draw[vector,red] (A0) -- (A4);
它应用了vector
样式和,因此红线为thick
。其他蓝线均使用\draw[blue] ...
不包含线条粗细规范的样式绘制,因此这些线条为默认粗细。
如果你想要相同的厚度,你可以用
\draw[vector,blue] ...
或者,您可以使用scope
并将样式应用于vector
该scope
。
笔记:
- 我还添加了
line join=round
以获得更好的图像。
代码:
\documentclass{article}
\usepackage{tikz,tikz-3dplot}
\usetikzlibrary{calc,arrows,positioning}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{tikzpicture}[scale=5,
vector/.style={thick,black,>=stealth,->},
atom/.style={blue}
]
\begin{axis}[
axis lines=none,
xmin=-0.1,
xmax=2.1,
ymin=-0.1,
ymax=2.1,
zmin=-0.1,
zmax=2.1,
%xtick=\empty,
%ytick=\empty,
%ztick=\empty
]
\coordinate (A0) at (axis cs:0,0,0);
\coordinate (A1) at (axis cs:0.2,0.5,0);
\coordinate (A2) at (axis cs:0.6,0.4,0);
\coordinate (A3) at (axis cs:0.8,0.9,0);
\coordinate (A4) at (axis cs:0.2,0,1);
\coordinate (A5) at (axis cs:0.4,0.5,1);
\coordinate (A6) at (axis cs:0.8,0.4,1);
\coordinate (A7) at (axis cs:1,0.9,1);
\begin{scope}[vector, line join=round]
\draw [blue] (A0) -- (A1) -- (A5) -- (A4) -- cycle;
\draw [blue] (A2) -- (A3) -- (A7) -- (A6) -- cycle;
\draw [blue] (A0) -- (A1) -- (A3) -- (A2) -- cycle;
\draw [blue] (A4) -- (A5) -- (A7) -- (A6) -- cycle;
\draw [red] (A0) -- (A4);
\end{scope}
\end{axis}
\end{tikzpicture}
\end{document}