pgfplots: 주요 그리드를 제거한 후 보조 그리드/틱 복원

pgfplots: 주요 그리드를 제거한 후 보조 그리드/틱 복원

수행원내 이전 질문0, 와 사이의 마이너 그리드가 제거된 것을 발견했습니다 0.5. 그래서 grid = minor안에 추가하려고 했는데extra tick style

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[
    xtick={0.5,1,...,4.5},
    xmin=0,xmax=5,
    minor x tick num = {1},
    minor x tick style = {line width = 2pt},
    major x tick style = {line width = 2pt},
    xmajorgrids, xminorgrids,
    major x grid style = {dashed,red},
    minor x grid style = {dotted,black},
    extra x ticks={0,5},
    extra tick style={
        grid=minor,
    },]
        \addplot[mark=none,blue] {x^2};
    \end{axis}
\end{tikzpicture}
\end{document}

하지만 결과는 이렇습니다

여기에 이미지 설명을 입력하세요

나에게 필요한 것은

  1. 05및 에서 주요 틱을 제거합니다.
  2. 작은 체크 표시를 하세요.0.25

여담이 되는 질문

에 작은 체크 표시가 있고 4.75에는 표시되지 않는 이유는 무엇입니까 0.25?

답변1

따라서 "반대로" 작업을 수행해야 합니다. 따라서 일반 틱의 스타일을 추가 틱에 적용하고 그 반대의 경우도 마찬가지입니다.

코드 작동 방식에 대한 주석입니다. (필요하지 않은 코드를 삭제했습니다.)

% used PGFPlots v1.14
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        xmin=0,xmax=5,
        % don't state the `xtick's here, but use just the default and state
        % the `xtick distance'
        xtick distance=0.5,
        minor x tick num={1},
        minor x tick style={line width=2pt},
        xminorgrids,
        minor x grid style={dotted,black},
        % but draw the `extra x ticks' with the values of the former `xtick' ...
        extra x ticks={0.5,1,...,4.5},
        % ... but don't draw any labels (because they are there already and
        % there is no need to draw them twice)
        extra x tick labels={},
        % finally apply the needed style for the extra ticks
        extra tick style={
            tick style={line width=2pt},
            major grid style={dashed,red},
            grid=major,
        },
    ]
        \addplot [mark=none,blue] {x^2};
    \end{axis}
\end{tikzpicture}
\end{document}

위 코드의 결과를 보여주는 이미지

관련 정보