我想要两个并排的倒三角形。中间应该有水平的箭头位于中间。我必须指定哪些坐标才能定位形状的边缘而不是内部节点?
\begin{tikzpicture}[
triangle/.style={fill=blue!20, regular polygon, regular polygon sides=3, align=center, minimum height=6cm},
]
\node [triangle, shape border rotate=180] (intensity) {descending};
\node [triangle, right=7cm of intensity.north, anchor=north] (sensitivity) {increasing};
\draw [<->] (intensity.north east) -- (sensitivity.north west);
\draw [<->] (intensity.east) -- (sensitivity.west);
\draw [<->] (intensity.south east) -- (sensitivity.south west);
\end{tikzpicture}
我想拥有水平的(红色)线。
答案1
您可以通过声明node_name.direction来获取一些形状点,这将在形状与从形状中心到方向的线的交点处找到一个点;在这种情况下,作为一个正三角形,您可以轻松获得角度。例如\draw [<->] (intensity.30) -- (sensitivity.90);
给出上面的第一条线;对于 instesity,角位于 30-150-270 方向,对于 则以 90,210,330 增加,对于边缘的中点,强度位于 90-210-330 方向,对于 则以 30-150-270 增加。当您使用时node_name.east
类似于并且对于、、node_name.0
也相同。north=90
west/=180
south=270
结果:
梅威瑟:
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,shapes,positioning}
\begin{document}
\begin{tikzpicture}[
triangle/.style={
fill=blue!20,
regular polygon,
regular polygon sides=3,
align=center,
minimum height=6cm
}
]
\node [triangle, shape border rotate=180] (intensity) {descending};
\node [triangle, right=7cm of intensity.north, anchor=north] (sensitivity) {increasing};
\draw [<->] (intensity.30) -- (sensitivity.90);
\draw [<->] (intensity.330) -- (sensitivity.150);
\draw [<->] (intensity.270) -- (sensitivity.210);
\end{tikzpicture}
\end{document}
测试和学习:
如果仅声明节点名称,则会出现定位问题,在原始示例中,使用形状中的特定点(如)来解决,即和right=7cm of intensity.north,anchor=north
之间的距离,该距离被声明为形状的敏感度锚点;然后我添加了带有描述的某些节点,更改了节点文本的位置;并测试五边形中的角节点。intensity.north
sensitivity.north
结果:
梅威瑟:
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,shapes,positioning}
\begin{document}
\begin{tikzpicture}[
triangle/.style={
fill=blue!20,
regular polygon,
regular polygon sides=3,
align=center,
minimum height=6cm
}
]
\draw
node[triangle, shape border rotate=180](intensity){}
(intensity.center |- intensity.330) node{descending} % Label aligned to mid line
node[triangle, right=7cm of intensity.north,anchor=north](sensitivity){}
(sensitivity.center |- sensitivity.150) node{increasing} % Label aligned to mid line
;
\draw [<->] (intensity.30) -- (sensitivity.90);
\draw [<->] (intensity.330) -- (sensitivity.150);
\draw [<->] (intensity.270) -- (sensitivity.210);
%Tesintg drawing
\foreach \n in {center,0,30,90,150,210,270,330}{
\draw[fill=blue]
(intensity.\n) circle (2pt) node[font=\scriptsize,anchor=90]{(intensity.\n)};
}
\foreach \n in {center,30,90,150,210,270,330}{
\draw[fill=blue]
(sensitivity.\n) circle (2pt) node[font=\scriptsize,anchor=90]{(sensitivity.\n)};
}
\draw[|-|,dashed](intensity.north)++(0,5pt)-- ++(7cm,0) node[midway,above,font=\scriptsize]{7cm};
\node[
fill=red!30,
regular polygon,
regular polygon sides=5,
align=center,
minimum size=5cm,
above right=1.5 and 1.5cm of intensity](test){};
\foreach \n in {center,west,east,54,90,126,198,270,342}{
\draw[fill=red]
(test.\n) circle (2pt) node[font=\scriptsize,anchor=-90]{(test.\n)};
}
\foreach \n in {1,...,5}{
\draw[fill=green]
(test.corner \n) circle (2pt) node[font=\scriptsize,anchor=90]{(test. corner\n)};
}
\end{tikzpicture}
\end{document}
答案2
\documentclass[border=5pt,tikz]{standalone}
\usetikzlibrary{shapes,positioning,calc}
\tikzset{
my/.style={
path picture={
\fill[blue!20] (path picture bounding box.south east) -- (path picture bounding box.north) -- (path picture bounding box.south west) -- cycle;
}
},
ma/.style={
path picture={
\fill[blue!20] (path picture bounding box.south) -- (path picture bounding box.north east) -- (path picture bounding box.north west) -- cycle;
}
},
}
\begin{document}
\begin{tikzpicture}[every node/.style={inner sep=0pt}]
\node[minimum height=6cm,minimum width=6cm,ma] (a) {};
\node[minimum height=6cm,minimum width=6cm,my,right=2 of a] (b) {};
\draw[red] (a.south) -- (b.south west);
\draw[red] ($(a.south)!.5!(a.north east)$) -- ($(b.south west)!.5!(b.north)$);
\draw[red] (a.north east) -- (b.north);
\node at (a) {descending};
\node at (b) {increasing};
\end{tikzpicture}
\end{document}