半實心圓標記

半實心圓標記

如何在軸上繪製半實心圓。我希望標記位於原點並填充在圓的左半部。

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

相關內容