2

How can I draw a half filled circle on my axis. I would like the marker to be at the origin and be filled on the left half of the circle.

\documentclass[12pt,]{article}  
\usepackage{graphicx}
\usepackage{pgfplots}
\begin{document}

%what i want my marker to look like         
  \begin{tikzpicture}
   \draw (0,0) circle (1cm);
   \clip (0,0) circle (1cm);
   \fill[black] (0cm,1cm) rectangle (-1cm,-1cm);
  \end{tikzpicture}

%what the graph looks like and the marker looks like
   \begin{tikzpicture}
    \begin{axis}[
    minor tick num=1,
    axis x line = center,
    axis y line = middle,
    xlabel={$x$},
    ylabel={$\dot{x}$},
    ymin=-5, ymax=5
    ] 

    %\draw[thin] (axis cs:1,0) circle [radius=3pt] node[above left] {$(1,0)$};
     \draw[fill] (axis cs:0,0) circle [radius=3pt] node[below right] {$(0,0)$};             
     \addplot [smooth,blue, mark=none,
      domain=-5:5] {x^2}; 
   \end{axis}
  \end{tikzpicture}
\end{document}
  • 1
    That's an existing marker halfcircle* rotated. Can you complete your example to a compilable TeX document? – percusse Sep 24 '14 at 22:24
  • Welcome to TeX.SE. – Peter Grill Sep 24 '14 at 23:43
  • When asking questions it is better to provide a full minimal working example (MWE) both in order to demonstrate what you are trying to do and to help others help you. The MWE should like like \documentclass...\begin{document}...\end{document}, it should compile and contain close to the minimal amount of code needed to explain/demonstrate what you are asking. This saves a lot of time for everyone. – Andrew Sep 25 '14 at 1:00
2

As per @percusse's comment you can use mark=halfcircle* and apply a rotation as shown at (0,0) below.

Alternatively, you could adapt your version and define a custom macro to place this as desired (as shown at (1,1)). This has the advantage that there is no fill applied to the white portion. Furthermore, you can use this technique to create any other marker type that you want to highlight special points.

enter image description here

Code:

\documentclass[12pt]{article}  
\usepackage{graphicx}
\usepackage{pgfplots}
\begin{document}

%%what i want my marker to look like         
%  \begin{tikzpicture}
%   \draw (0,0) circle (1cm);
%   \clip (0,0) circle (1cm);
%   \fill[black] (0cm,1cm) rectangle (-1cm,-1cm);
%  \end{tikzpicture}
%  
\newcommand{\MyHalfCircle}[3][0.4ex]{%
    % #1 = size
    % #2 = x coordinate
    % #3 = y coordinate
  \begin{scope}
   \draw (axis cs:#2,#3) circle (#1);
   \clip (axis cs:#2,#3) circle (#1);
   \fill[red, opacity=0.75] (axis cs:#2,#1) rectangle (axis cs:-#1,-#1);
  \end{scope}
}

%what the graph looks like and the marker looks like
   \begin{tikzpicture}
    \begin{axis}[
    minor tick num=1,
    axis x line = center,
    axis y line = middle,
    xlabel={$x$},
    ylabel={$\dot{x}$},
    ymin=-5, ymax=5
    ] 

     \addplot [smooth,blue, mark=none,thick,  domain=-5:5] {x^2}; 
     \addplot [mark=halfcircle*, mark options={rotate=90}] coordinates {(0,0)}; 
     \MyHalfCircle{1}{1};
   \end{axis}
  \end{tikzpicture}
\end{document}

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.