其他颜色的弧线有效。为什么蓝色弧线给出 Ti钾Z 投诉?
\begin{figure}[h]
\begin{center}
\begin{tikzpicture}[scale=1.5 ,cap = round, color = blue]
\draw [ ultra thick, blue] [- ] (-2,0)--( 2,0) ; %x axis
\draw [ ultra thick, blue] [-] ( ( 0,-2) --( 0,2) % y axis
% PROBLEM HERE at \drawfill Why
\drawfill [ ultra thick, blue, opacity= 0.5, fill= blue] (-2,0) arc ( 180: 270: 2 );
% error \draw [ultra thick, blue, opacity= 0.5, fill= blue ] ( -2,0) arc ( 180: 270: 2 ) ;
\draw [ ultra thick, blue, opacity= 0.5, fill= yellow ] (0,2) arc ( 90: 180: 2 ) ;
\draw [ ultra thick, blue, opacity= 0.5, fill= red ] (2,0) arc ( 0: 90: 2 ) ;
\draw [ ultra thick, blue, opacity= 0.5, fill= green ] (0,-2) arc ( 270: 360: 2 ) ;
% label 4 corners
%%% labels A B C D
\draw ( 0,2) node[ above ] {A};
\draw ( 0,-2) node[ below ] { C};
\draw ( -2,0 ) node[ above left ] { B};
\draw ( 2,0 ) node[ above right ] { D};
\end{tikzpicture}
\end{center}
\end{figure}
答案1
一个很好的@Jasper Habicht 回答的题外话(+1):
- 定义坐标,并标注坐标标签
- 定义填充样式
arc
- 不曾用过
fill opacity
\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale = 1.5, ultra thick, color=blue,
fa/.style = {fill=#1!50} % fill arc
]
% label 4 corners
\coordinate[label=A] (a) at ( 0,2);
\coordinate[label= left:B] (b) at (-2,0);
\coordinate[label=below:C] (c) at (0,-2);
\coordinate[label=right:D] (d) at ( 2,0);
% linea
\draw (b) -- (d) % x axis
(a) -- (c); % y axis
% filled areas
\draw[fa=yellow] (a) arc (90:180:2);
\draw[fa=blue] (b) arc (180:270:2);
\draw[fa=green] (c) arc (270:360:2);
\draw[fa=red] (d) arc (0:90:2);
\end{tikzpicture}
\end{document}
附录: 受到以下@Qrrbrbirlbel 评论的启发。代码是最新的,而且更简洁:
\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale = 1.5, ultra thick, color=blue,
fa/.style = {fill=#1!50} % fill arc
]
% label 4 corners
\coordinate[label=A] (1) at ( 0,2);
\coordinate[label= left:B] (2) at (-2,0);
\coordinate[label=below:C] (3) at (0,-2);
\coordinate[label=right:D] (4) at ( 2,0);
% linea
\draw (2) -- (4) % x axis
(1) -- (3); % y axis
% filled areas
\begin{scope}[radius=2, delta angle=90]
\foreach \i [count=\j] in {yellow, blue, green, red}
\draw[fa=\i] (\j) arc[start angle=\j*90];
\end{scope}
\end{tikzpicture}
\end{document}
结果与第一次 MWE 相同。
答案2
你应该确保每一个 Ti钾Z 语句以分号结尾。有时从错误消息中无法直接看出哪一行缺少分号。因此,我建议您在整个代码中应用某些间距规则,因为这对查找缺失或虚假字符大有帮助。
在这个具体案例中,罪魁祸首是这条线前您认为有错误的那行,因为它没有以分号结尾;
,并且还有一个虚假的开括号(
。除此之外,Ti钾Z 只知道\filldraw
宏,但不知道\drawfill
。无论如何,既然你已经\draw[fill]
在其他弧段中使用了,我会坚持使用这个版本,因为它本质上具有相同的含义,
我不确定[-]
应该表示什么,所以我从下面更简洁的代码版本中删除了它。另外,我可能会改为,opacity
因为fill opactiy
我猜你也不希望圆弧段的边框透明。
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=1.5, cap=round, color=blue]
\draw[ultra thick, blue] (-2,0) -- (2,0); % x axis
\draw[ultra thick, blue] (0,-2) -- (0,2); % y axis
\draw[ultra thick, blue, fill opacity=0.5, fill=blue] (-2,0) arc (180:270:2);
\draw[ultra thick, blue, fill opacity=0.5, fill=yellow] (0,2) arc (90:180:2);
\draw[ultra thick, blue, fill opacity=0.5, fill=red] (2,0) arc (0:90:2);
\draw[ultra thick, blue, fill opacity=0.5, fill=green] (0,-2) arc (270:360:2);
% label 4 corners
%%% labels A B C D
\draw (0,2) node[above] {A};
\draw (0,-2) node[below] {C};
\draw (-2,0) node[above left] {B};
\draw (2,0) node[above right] {D};
\end{tikzpicture}
\end{document}