2

A typical form for a node in TikZ is a circle around the text of the node. The shapes packages provides lot of other forms. What I couldn't find is an open half circle (or ellipse) under the node. Any ideas or hints on that? Cheers Renger

  • 1
    Are you searching for semicircle? – Symbol 1 Aug 18 '17 at 14:30
  • No, semicircle is upside down and is closed, I want to have it open (like a bowl below the node) – arnyeinstein Aug 18 '17 at 17:13
  • See this question: tex.stackexchange.com/questions/33150/creating-node-shapes How do I mark a question as duplicate? – Julian_W Aug 18 '17 at 19:56
  • 3
    How about \node(A){some text}; and then \draw(A.west)to[bend right=45](A.east);? – Symbol 1 Aug 18 '17 at 20:41
2

This is mainly inspired from: Creating node shapes

However it is just oriented in one direction here. I'm sure one can improve it to make it easily rotatable.

\documentclass{article}
\usepackage{tikz}

\makeatletter
\tikzset{arc style/.initial={}}
\pgfdeclareshape{half circle}{
  \inheritsavedanchors[from=circle]
  \inheritanchorborder[from=circle]

  \inheritanchor[from=circle]{center}
  \inheritanchor[from=circle]{south}
  \inheritanchor[from=circle]{west}
  \inheritanchor[from=circle]{north}
  \inheritanchor[from=circle]{east}
  % can add more anchors if necessary

  \inheritbackgroundpath[from=circle]

  \beforebackgroundpath{
    % get and set options
    \pgfkeys{/tikz/arc style/.get=\tmp}
    \expandafter\tikzset\expandafter{\tmp}
    \tikz@options

    % get radius length and center coordinates
    \radius \pgf@xa=\pgf@x
    \centerpoint \pgf@xb=\pgf@x \pgf@yb=\pgf@y

    % draw arc
    \advance\pgf@yb by \pgf@xa
    \pgfpathmoveto{\pgfpoint{\pgf@xb}{\pgf@yb}}
    \pgfpatharc{90}{-90}{\pgf@xa}
    % change the last line to the following line if you want the half circle rotated in the other direction
    % \pgfpatharc{90}{270}{\pgf@xa}

    \pgfusepath{draw}
  }
}
\makeatother

\begin{document}
\begin{tikzpicture}
  \node[
    half circle,
    fill=red!10,  % can fill the circle if needed
    minimum width=2cm,
    arc style={red,thick}
    ] (c) {my half circle};

\end{tikzpicture}
\end{document}

output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.