是否可以在节点内绘制具有特定长度、角度和颜色的线。我使用以下代码在节点内绘制一个圆圈和一些模仿线的东西。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw [thick, blue, densely dashed] (0,0) node[red, xshift=.5cm, yshift=0cm]{\large I} node [xshift=1cm, yshift=0cm, circle, draw,solid, green, fill=green, scale=0.8]{} -- (3,0);
\draw [thick, blue, densely dashed] (0,0) node[red, xshift=0cm, yshift=1cm]{\Huge -} -- (0,3);
\end{tikzpicture}
\end{document}
这使
答案1
当然,用path picture
s,例如
path picture={
\draw[blue] (path picture bounding box.west) -- (path picture bounding box.east);
}
完成 MWE:
\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}
\node [circle, draw,solid, green, fill=green,minimum width=2cm,
path picture={
\draw[blue] (path picture bounding box.west) -- (path picture bounding box.east);
}]{} ;
\end{tikzpicture}
\end{document}
如果您告诉我您在例子中想到了什么,也许我知道如何去做。
更新:只是为了好玩:刻度线。我也在层上绘制节点background
,但当然,如果我在线之前绘制它,结果会是一样的。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{backgrounds,plotmarks}
\begin{document}
\begin{tikzpicture}
\draw [thick, blue, densely dashed] (0,0) -- (3,0);
\draw [thick, blue, densely dashed] (0,0) -- (0,3);
\foreach \X in {1,2}
{\node[red] (x-\X) at (\X,0){\pgfuseplotmark{|}};
\node[red] (y-\X) at (0,\X){\pgfuseplotmark{-}};}
\begin{scope}[on background layer]
\node [circle, draw,solid, green, fill=green, scale=0.8]
at (x-1){};
\end{scope}
\end{tikzpicture}
\end{document}