将圆形节点修改为半圆形节点,并在图下方添加标题

将圆形节点修改为半圆形节点,并在图下方添加标题

这是 floor 函数图的代码。我想做一些修改,如下所示:

  1. 将红色圆圈改为红色半圆

  2. 轴上有两个零,我想删除其中一个

  3. 最后我想在情节下面添加一个标题。在此处输入图片描述

\documentclass{article}
\usepackage{pgf,tikz,pgfplots,tkz-base}
\begin{document}
\begin{tikzpicture}
    \tkzInit[xmin = -3, xmax = 3, ymin = -3, ymax = 3]
    \tkzAxeXY
    \foreach \a in {-3,...,3}{
        \draw[blue] (\a, \a) -- (\a + 1, \a);
        \node [circle, draw, fill, line width = .5pt, color = blue, inner sep = 0pt, minimum size = 3pt] (ca) at (\a, \a) {};
        \node [circle, draw, fill=none, line width = .5pt, color = red, inner sep = 0pt, minimum size = 3pt] (ca) at (\a + 1, \a) {};
    } 
    \end{tikzpicture}
\end{document}

答案1

您可以剪掉圆的一半,比如说orig=false移除它0并在轴下方放置一个简单的节点。

\documentclass{article}
\usepackage{tikz,tkz-base}
\begin{document}
\begin{tikzpicture}
    \tkzInit[xmin = -3, xmax = 3, ymin = -3, ymax = 3]
    \tkzAxeX[orig=false]
    \tkzAxeY
    \foreach \a in {-3,...,3}{
        \draw[blue] (\a, \a) -- (\a + 1, \a);
        \node [circle, draw, fill, line width = .5pt, color = blue, inner sep = 0pt, minimum size = 3pt] (ca) at (\a, \a) {};
        \begin{scope}
        \clip ([xshift=-1em,yshift=-1em]\a + 1, \a) rectangle 
        ([yshift=1em]\a + 1, \a);
        \node [circle, draw, fill=none, line width = .5pt, color = red, inner sep = 0pt, minimum size = 3pt] (ca) at (\a + 1, \a) {};
        \end{scope}
    } 
    \node[below] at (0,-3.2) {title of the plot};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容