在原点添加标签“0”,更改标记并移动标签

在原点添加标签“0”,更改标记并移动标签

我想拥有

  • 原点处的标签“0”,
  • 圆圈标记替换 tik 标记(垂直划线)
  • 并向右移动

以免干扰“y”线。

我尝试了几种方法,但都没有成功。:/ 知道该怎么做吗?

在此处输入图片描述

%%%%%%%%%%%%%%%%%% INTRODUCTION %%%%%%%%%%%%%%%%%%
\documentclass[]{standalone}

%%%%%%%%%%%%%%%%%% INPUT %%%%%%%%%%%%%%%%%%
%\input{preamble.tex}
%\input{parameters.tex}

%%%%%%%%%%%%%%%%%% PACKAGE %%%%%%%%%%%%%%%%%%
\usepackage{tikz, tkz-euclide}%  permet de dessiner des figures, des graphiques
\usepackage{pgfplots}
%\usepackage{adjustbox}% permet de déterminer une taille de fenêtre
%%  FONT
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%
\usepackage{tgadventor}% paquet de police de caractère TGadventor
\usepackage{sansmath}%  Copie-colle la police active dans 
%                       \sfdefault (/!\ N'EST PAS UNE POLICE DE CARACTÈRES)
\usepackage{xcolor}
\usetikzlibrary{matrix,arrows,calc,math,shapes,arrows.meta,backgrounds}
%%%%
\tikzset{%
    graphpgf/.style={%
        font={\sansmath\sffamily\Large}, 
        line cap=round, line join=round, 
        >={Latex[length=3mm]}, 
        x=1.0cm, y=1.0cm, 
        background rectangle/.style={fill=white, shift={(0pt, 0pt)}},
        show background rectangle,
        inner frame sep=15pt
    }
}

%%%     Paramètre graphique des graphiques orthonormés pgfplots
\pgfplotsset{/pgfplots/graphxy/.style={
        %%%%%%%%%%  Dimensionnement de l'image  %%%%%%%%%%
        width=12cm,
        height=12cm,
        unit vector ratio=1 1 1,
        %%%%%%%%%%  esthétique des axes  %%%%%%%%%%
        xlabel=$\mathrm{x}$,         ylabel=$\mathrm{y}$,
        axis lines = middle,
        enlargelimits=false,
        line width=0.4mm,
        every major grid/.append style={black!20, line width=0.35mm,},
        every minor grid/.append style={black!15, line width=0.15mm,},
        every major tick/.append style={line width=0.4 mm, major tick length=7pt, black},
        every minor tick/.append style={line width=0.15mm, minor tick length=4pt, black},
        %axis background/.style={fill=white},
        grid=both,
        axis line style = {shorten >=-12.5pt, shorten <=-12.5pt, -{Latex[length=3mm]}},
        xlabel style={at={(ticklabel* cs:1)},yshift=-3.5pt, anchor=north west, font=\sansmath\sffamily\Large},
        ylabel style={at={(ticklabel* cs:1)},xshift=-3.5pt,, anchor=south east, font=\sansmath\sffamily\Large},
        title style = {font=\sansmath\sffamily\Large, align=center, inner sep=12pt,},
        }
    }

%%%%%%%%%%%%%%%%%% DOCUMENT %%%%%%%%%%%%%%%%%%
\begin{document}
\begin{tikzpicture}[graphpgf]

%%%%%%%%%%%%%%%%%% Data Table %%%%%%%%%%%%%%%%%%
\begin{axis}[%
    graphxy,
    %%%     Axe x
    xlabel=$\mathrm{n}$,
    extra x ticks={0},
    extra x tick style={%
        mark=*,
        %anchor=south east,
        %ticklabel pos=below right
        },
    xmin=-0-.5, xmax=11+.5,
    xtick={-15,...,15},
    %minor xtick={-10,...,8},
    domain=-3:3,
    %%%     Axe x
    ylabel=$\mathrm{u_n}$,
    ymin=-0.3-.5,ymax=7+.5,
    ytick={-15,...,15},
    %minor ytick={-8,...,8},
    %minor tick num=1,
    restrict y to domain=-6:6,
           ]%
\end{axis}

\end{tikzpicture}
\end{document}

最后结果

在此处输入图片描述

代码:

%%%%%%%%%%%%%%%%%% INTRODUCTION %%%%%%%%%%%%%%%%%%
\documentclass[]{standalone}

%%%%%%%%%%%%%%%%%% INPUT %%%%%%%%%%%%%%%%%%
%\input{preamble.tex}
%\input{parameters.tex}

%%%%%%%%%%%%%%%%%% PACKAGE %%%%%%%%%%%%%%%%%%
\usepackage{tikz, tkz-euclide}%  permet de dessiner des figures, des graphiques
\usepackage{pgfplots}
%%  FONT
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%
\usepackage{tgadventor}% paquet de police de caractère TGadventor
\usepackage{sansmath}%  Copie-colle la police active dans 
%                       \sfdefault (/!\ N'EST PAS UNE POLICE DE CARACTÈRES)
\usepackage{xcolor}
\usetikzlibrary{%
    matrix,
    arrows,
    arrows.meta,
    calc,
    math,
    shapes,
    backgrounds,
    decorations.markings,
    }
%%%%
\tikzset{%
    graphpgf/.style={%
        font={\sansmath\sffamily\Large}, 
        line cap=round, line join=round, 
        >={Latex[length=3mm]}, 
        x=1.0cm, y=1.0cm, 
        background rectangle/.style={fill=white, shift={(0pt, 0pt)}},
        show background rectangle,
        inner frame sep=15pt
    }
}

%%%     Paramètre graphique des graphiques orthonormés pgfplots
\pgfplotsset{%
    /pgfplots/graphxy/.style={%
        %%%%%%%%%%  Dimensionnement de l'image  %%%%%%%%%%
        width=12.5cm,
        height=12.5cm,
        unit vector ratio=1 1 1,
        %%%%%%%%%%  esthétique des axes  %%%%%%%%%%
        xlabel=$\mathrm{x}$,         ylabel=$\mathrm{y}$,
        axis lines = middle,
        enlargelimits=false,
        line width=0.4mm,
        every major grid/.append style={black!20, line width=0.35mm,},
        every minor grid/.append style={black!15, line width=0.15mm,},
        every major tick/.append style={line width=0.4 mm, major tick length=7pt, black},
        every minor tick/.append style={line width=0.15mm, minor tick length=4pt, black},
        %axis background/.style={fill=white},
        grid=both,
        axis line style = {shorten >=-12.5pt, shorten <=-12.5pt, -{Latex[length=3mm]}},
        xlabel style={at={(ticklabel* cs:1)},yshift=-3.5pt, anchor=north west, font=\sansmath\sffamily\Large},
        ylabel style={at={(ticklabel* cs:1)},xshift=-3.5pt,, anchor=south east, font=\sansmath\sffamily\Large},
        title style = {font=\sansmath\sffamily\Large, align=center, inner sep=12pt,},
        extra x ticks={0},
        extra x tick style={%
            grid= none,
            xticklabel style={%
                below right,
            },
            every major tick/.append style={
                scale=1,
                draw=none,
                postaction={decorate},
                decoration={
                    markings,
                    mark=between positions 3.5pt and 1 step 7pt with{
                      \draw[fill] (0, 0) circle (2pt);
                    },
                },
            },
        },
    }
}

%%%%%%%%%%%%%%%%%% DOCUMENT %%%%%%%%%%%%%%%%%%
\begin{document}
\begin{tikzpicture}[graphpgf]

%%%%%%%%%%%%%%%%%% Data Table %%%%%%%%%%%%%%%%%%
\begin{axis}[%
    graphxy,
    %%%     Axe x
    xlabel=$\mathrm{n}$,
    extra x ticks={0},
    extra x tick style={%
        xticklabel style={below right},
        every major grid/.append style={black,},
        every major tick/.append style={black},
        },
    xmin=-0-.5, xmax=11+.5,
    xtick={-15,...,15},
    %minor xtick={-10,...,8},
    domain=-3:3,
    %%%     Axe x
    ylabel=$\mathrm{u_n}$,
    ymin=-0-.5,ymax=7+.5,
    ytick={-15,...,15},
    %minor ytick={-8,...,8},
    %minor tick num=1,
    restrict y to domain=-6:6,
           ]%
\end{axis}

\end{tikzpicture}
\end{document}

答案1

您可以使用ticklabel来指定想要用作额外刻度 0 的标签文本。

这里我以大写字母O为例:

    extra x tick style={
      xticklabel style={below left}, 
      xticklabel={O}
    },

完整示例:

\documentclass[]{standalone}

%%%%%%%%%%%%%%%%%% INPUT %%%%%%%%%%%%%%%%%%
%\input{preamble.tex}
%\input{parameters.tex}

%%%%%%%%%%%%%%%%%% PACKAGE %%%%%%%%%%%%%%%%%%
\usepackage{tikz, tkz-euclide}%  permet de dessiner des figures, des graphiques
\usepackage{pgfplots}
%\usepackage{adjustbox}% permet de déterminer une taille de fenêtre
%%  FONT
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%
\usepackage{tgadventor}% paquet de police de caractère TGadventor
\usepackage{sansmath}%  Copie-colle la police active dans 
%                       \sfdefault (/!\ N'EST PAS UNE POLICE DE CARACTÈRES)
\usepackage{xcolor}
\usetikzlibrary{matrix,arrows,calc,math,shapes,arrows.meta,backgrounds}
%%%%
\tikzset{%
    graphpgf/.style={%
        font={\sansmath\sffamily\Large}, 
        line cap=round, line join=round, 
        >={Latex[length=3mm]}, 
        x=1.0cm, y=1.0cm, 
        background rectangle/.style={fill=white, shift={(0pt, 0pt)}},
        show background rectangle,
        inner frame sep=15pt
    }
}

%%%     Paramètre graphique des graphiques orthonormés pgfplots
\pgfplotsset{/pgfplots/graphxy/.style={
        %%%%%%%%%%  Dimensionnement de l'image  %%%%%%%%%%
        width=12cm,
        height=12cm,
        unit vector ratio=1 1 1,
        %%%%%%%%%%  esthétique des axes  %%%%%%%%%%
        xlabel=$\mathrm{x}$,         ylabel=$\mathrm{y}$,
        axis lines = middle,
        enlargelimits=false,
        line width=0.4mm,
        every major grid/.append style={black!20, line width=0.35mm,},
        every minor grid/.append style={black!15, line width=0.15mm,},
        every major tick/.append style={line width=0.4 mm, major tick length=7pt, black},
        every minor tick/.append style={line width=0.15mm, minor tick length=4pt, black},
        %axis background/.style={fill=white},
        grid=both,
        axis line style = {shorten >=-12.5pt, shorten <=-12.5pt, -{Latex[length=3mm]}},
        xlabel style={at={(ticklabel* cs:1)},yshift=-3.5pt, anchor=north west, font=\sansmath\sffamily\Large},
        ylabel style={at={(ticklabel* cs:1)},xshift=-3.5pt,, anchor=south east, font=\sansmath\sffamily\Large},
        title style = {font=\sansmath\sffamily\Large, align=center, inner sep=12pt,},
        }
    }

%%%%%%%%%%%%%%%%%% DOCUMENT %%%%%%%%%%%%%%%%%%
\begin{document}
\begin{tikzpicture}[graphpgf]

%%%%%%%%%%%%%%%%%% Data Table %%%%%%%%%%%%%%%%%%
\begin{axis}[%
    graphxy,
    %%%     Axe x
    xlabel=$\mathrm{n}$,
    extra x ticks={0},
    extra x tick style={
      xticklabel style={below right}, 
      xticklabel={O}
    },
    xmin=-0-.5, xmax=11+.5,
    xtick={-15,...,15},
    %minor xtick={-10,...,8},
    domain=-3:3,
    %%%     Axe x
    ylabel=$\mathrm{u_n}$,
    ymin=-0.3-.5,ymax=7+.5,
    ytick={-15,...,15},
    %minor ytick={-8,...,8},
    %minor tick num=1,
    restrict y to domain=-6:6,
           ]%
\end{axis}

\end{tikzpicture}
\end{document}

在此处输入图片描述

更新

为了用实心圆代替刻度线,使用了路径装饰。

% in preamble
\usetikzlibrary{decorations.markings}

% new option added to "axis" environment
    tick style={
      draw=none,
      red, thick, % for highlighting
      postaction={decorate},
      decoration={
        markings,
        % 7pt is from "major tick length=7pt", and 3.5pt is half of 7pt
        mark=between positions 3.5pt and 1 step 7pt with {
          \draw[fill] (0, 0) circle (2pt);
        }
      }
    },

完整示例

\documentclass[]{standalone}

%%%%%%%%%%%%%%%%%% INPUT %%%%%%%%%%%%%%%%%%
%\input{preamble.tex}
%\input{parameters.tex}

%%%%%%%%%%%%%%%%%% PACKAGE %%%%%%%%%%%%%%%%%%
\usepackage{tikz, tkz-euclide}%  permet de dessiner des figures, des graphiques
\usetikzlibrary{decorations.markings}

\usepackage{pgfplots}
%\usepackage{adjustbox}% permet de déterminer une taille de fenêtre
%%  FONT
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%
\usepackage{tgadventor}% paquet de police de caractère TGadventor
\usepackage{sansmath}%  Copie-colle la police active dans 
%                       \sfdefault (/!\ N'EST PAS UNE POLICE DE CARACTÈRES)
\usepackage{xcolor}
\usetikzlibrary{matrix,arrows,calc,math,shapes,arrows.meta,backgrounds}
%%%%
\tikzset{%
    graphpgf/.style={%
        font={\sansmath\sffamily\Large}, 
        line cap=round, line join=round, 
        >={Latex[length=3mm]}, 
        x=1.0cm, y=1.0cm, 
        background rectangle/.style={fill=white, shift={(0pt, 0pt)}},
        show background rectangle,
        inner frame sep=15pt
    }
}

%%%     Paramètre graphique des graphiques orthonormés pgfplots
\pgfplotsset{/pgfplots/graphxy/.style={
        %%%%%%%%%%  Dimensionnement de l'image  %%%%%%%%%%
        width=12cm,
        height=12cm,
        unit vector ratio=1 1 1,
        %%%%%%%%%%  esthétique des axes  %%%%%%%%%%
        xlabel=$\mathrm{x}$,         ylabel=$\mathrm{y}$,
        axis lines = middle,
        enlargelimits=false,
        line width=0.4mm,
        every major grid/.append style={black!20, line width=0.35mm,},
        every minor grid/.append style={black!15, line width=0.15mm,},
        every major tick/.append style={line width=0.4 mm, major tick length=7pt, black},
        every minor tick/.append style={line width=0.15mm, minor tick length=4pt, black},
        %axis background/.style={fill=white},
        grid=both,
        axis line style = {shorten >=-12.5pt, shorten <=-12.5pt, -{Latex[length=3mm]}},
        xlabel style={at={(ticklabel* cs:1)},yshift=-3.5pt, anchor=north west, font=\sansmath\sffamily\Large},
        ylabel style={at={(ticklabel* cs:1)},xshift=-3.5pt,, anchor=south east, font=\sansmath\sffamily\Large},
        title style = {font=\sansmath\sffamily\Large, align=center, inner sep=12pt,},
        }
    }

%%%%%%%%%%%%%%%%%% DOCUMENT %%%%%%%%%%%%%%%%%%
\begin{document}
\begin{tikzpicture}[graphpgf]

%%%%%%%%%%%%%%%%%% Data Table %%%%%%%%%%%%%%%%%%
\begin{axis}[%
    graphxy,
    %%%     Axe x
    xlabel=$\mathrm{n}$,
    extra x ticks={0},
%    extra x tick style={
%      xticklabel style={below right}, 
%      xticklabel={O}
%    },
    xmin=-0-.5, xmax=11+.5,
    xtick={-15,...,15},
    %minor xtick={-10,...,8},
    domain=-3:3,
    %%%     Axe x
    ylabel=$\mathrm{u_n}$,
    ymin=-0.3-.5,ymax=7+.5,
    ytick={-15,...,15},
    %minor ytick={-8,...,8},
    %minor tick num=1,
    restrict y to domain=-6:6,
    tick style={
      draw=none,
      red, thick, % for highlighting
      postaction={decorate},
      decoration={
        markings,
        % 7pt is from "major tick length=7pt", and 3.5pt is half of 7pt
        mark=between positions 3.5pt and 1 step 7pt with {
          \draw[fill] (0, 0) circle (2pt);
        }
      }
    },
]%
\end{axis}

\end{tikzpicture}
\end{document}

在此处输入图片描述

请注意,y 轴上的刻度被 x=0 处额外的 x 刻度网格线覆盖。我会看看是否可以轻松修复此问题。

相关内容