倒三角形作为节点形状

倒三角形作为节点形状

如何使节点呈现倒三角形的形状(底部在顶部)?

我尝试了以下操作:

triangle/.style = { regular polygon, regular polygon sides=3, rotate=180}

但我不想让文本旋转。

答案1

解决方案是使用shape border rotate而不是rotate

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture} [
    triangle/.style = {fill=blue!20, regular polygon, regular polygon sides=3 },
    node rotated/.style = {rotate=180},
    border rotated/.style = {shape border rotate=180}
  ]
    \node[triangle, node rotated] (a) {Bad triangle};
    \node[triangle, border rotated, right=6cm of a] {Good triangle};
\end{tikzpicture}
\end{document}

答案2

这是上述答案的更简单的代码,使用shape border rotate

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
 \node[regular polygon,regular polygon sides=3, draw, shape border rotate=180] at (0,0){Non-rotated text};
\end{tikzpicture}
\end{document}

相关内容