半实心圆圈标记

半实心圆圈标记

如何在轴上绘制一个半实心圆。我希望标记位于原点,并在圆的左半部分填充。

\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

根据@percusse 的评论,您可以使用mark=halfcircle*并应用旋转,如下所示(0,0)

或者,您可以调整您的版本并定义自定义宏以将其放置在所需位置(如图所示(1,1))。这样做的好处是不会fill应用于白色部分。此外,您可以使用此技术创建您想要突出显示特殊点的任何其他标记类型。

在此处输入图片描述

代码:

\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}

相关内容