我需要以下图片的帮助。
我无法在两个轴上绘制圆角矩形、左图中的 U 形线以及右图中元素的边界线。
这是我的尝试。
\begin{tikzpicture}[every node/.append style={font=\sffamily\footnotesize}] \begin{axis}[
axis y line = left,
axis x line = bottom,
xtick = {1,2,...,6},
ytick = {1,2,3},
ticklabel style = {font = \sffamily\footnotesize},
grid,
grid style = {color=gray, dotted},
xmin = 0, xmax = 6.5,
ymin = 0, ymax = 2.5,
]
\draw[fill=blue!70, draw=blue!80] (axis cs:1,1) circle (0.1cm);
\draw[fill=blue!70, draw=blue!80] (axis cs:2,1) circle (0.1cm);
\draw[fill=blue!70, draw=blue!80] (axis cs:3,2) circle (0.1cm);
\draw[fill=blue!70, draw=blue!80] (axis cs:5,2) circle (0.1cm);
\end{axis} \end{tikzpicture}
答案1
如果你考虑一个普通的 Ti钾Z 解决方案,这是可能的。我给你三种选择:用或使用库(也可以用)绘制一条double
线、一个多边形。rounded corners
fit
rounded corners
像这样:
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{fit}
\begin{document}
\begin{tikzpicture}[y=2cm,line cap=round,line join=round]
% with double line
\draw[cyan,double,double distance=5mm] (1,1) -- (2,1) -- (3,2) -- (5,2);
% axes and grid
\draw[latex-latex] (0,2.5) |- (6.5,0);
\foreach\i in {1,...,6}
{
\draw (\i,0.05) -- (\i,-0.05) node [below] {$\i$};
\draw[gray,dotted] (\i,0.05) -- (\i,2.5);
}
\foreach\i in {1,2}
{
\draw (0.1,\i) -- (-0.1,\i) node (\i) [left] {$\i$};
\draw[gray,dotted] (0.1,\i) -- (6.5,\i);
}
% dots
\foreach\x/\y in {1/1,2/1,3/2,5/2}
\fill[blue!80] (\x,\y) circle [radius=1mm];
% with rounded corners
\draw[cyan,rounded corners=0.2cm] (0.75,-0.25) rectangle (6.25,0.125);
% with fit and rounded corners
\node[draw=cyan,rounded corners=0.2cm,inner sep=2mm,fit=(1) (2)] {};
\end{tikzpicture}
\end{document}