Tikzpicture - 주요 진드기를 더 길거나 두껍게 만드는 방법

Tikzpicture - 주요 진드기를 더 길거나 두껍게 만드는 방법

상자 그림 통계를 더 쉽게 볼 수 있도록 주요 눈금(11,12,13,14,15,16,17,18,19 및 20)을 더 두껍거나 길게 만들려고 합니다. 누구든지 이것을 달성하는 방법을 알고 있습니까?

\documentclass{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{amssymb}
\usetikzlibrary{patterns}
\usepackage{xcolor}
\usetikzlibrary{arrows}
\usepgfplotslibrary{fillbetween}
\usepgfplotslibrary{statistics}
\usetikzlibrary{shapes.misc}
\begin{document}
\begin{tikzpicture}
\pgfmathsetlengthmacro\MajorTickLength{
    \pgfkeysvalueof{/pgfplots/major tick length} * 4
}
\begin{axis}
[
ytick=\empty,
xmin=11,
xmax=20,
xmajorticks=true,
minor x tick num=4,
xtick={11,12,13,14,15,16,17,18,19,20},
axis x line=bottom,
axis line style={latex-latex},
axis y line=none,
enlargelimits=0.05,
height=3.5cm,
width=13cm,
clip=false
]

\addplot[
yshift=0.1cm,
boxplot prepared={
median=15.5,
upper quartile=17.6,
lower whisker=11,
lower quartile=13.6,
upper whisker=19,
whisker extend=0 % height of whiskers
},black
] coordinates {};
%
\end{axis}
\end{tikzpicture}
\end{document}

감사합니다!

전류 출력

답변1

342쪽에서수동(버전 1.16)에서는 사용자 정의 옵션을 every minor tick/.append style={...}소개 합니다. 당신은 내부 를 every major tick/.append style={...}사용해야합니다 . 귀하의 코드를 최소한의 예로 압축했습니다.minor tick length = somethingmajor tick length= something

PS는 필요하지 않습니다 \pgfmathsetlengthmacro\MajorTickLength{...}.

산출

\documentclass{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\usepackage{tikz}
\pgfplotsset{compat = newest} % Current version is 1.16

\usepgfplotslibrary{statistics}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
ytick=\empty,
xmin=11,
xmax=20,
minor x tick num=4,
xtick={11,12,13,14,15,16,17,18,19,20},
%%%%%%%%%%%%%%%%%%%% What you need:
every major tick/.append style={very thick, major tick length=10pt, black},
every minor tick/.append style={thick, minor tick length=3pt, red},
%%%%%%%%%%%%%%%%%%%%
axis x line=bottom,
axis line style={latex-latex},
axis y line=none,
enlargelimits=0.05,
height=3.5cm,
width=13cm,
clip=false,
]
\addplot[
yshift=0.2cm,
boxplot prepared={
median=15.5,
upper quartile=17.6,
lower whisker=11,
lower quartile=13.6,
upper whisker=19,
whisker extend=0 % height of whiskers
},black
] coordinates {};
%
\end{axis}
\end{tikzpicture}
\end{document}

답변2

방금 \pgfmathsetlengthmacro\MajorTickLength{...}길이를 생성하고 여기에 값을 저장했지만 결코적용된그 가치는 어딘가에 있다. 따라서 major tick length=\MajorTickLength을 추가하면 axis원하지 않는 결과를 얻을 수 있습니다.

M. Al Jumaily가 했던 것처럼 코드를 대폭 단순화했습니다.그의 대답또한 - 동일한 결과를 얻으려면 ...

% used PGFPlots v1.16
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \usepgfplotslibrary{statistics}
\begin{document}
\begin{tikzpicture}
    \pgfmathsetlengthmacro\MajorTickLength{
        \pgfkeysvalueof{/pgfplots/major tick length} * 4
    }
    \begin{axis}[
        height=4cm,             % <-- (adjusted)
        width=13cm,
        axis x line=bottom,
        axis y line=none,
        axis line style={latex-latex},
        xmin=11,
        xmax=20,
        xtick distance=1,       % <-- (added)
        minor x tick num=4,
        ytick=\empty,
        major tick length=\MajorTickLength, % <-- added
        enlarge x limits=0.05,  % <-- (changed)
        enlarge y limits=0.25,  % <-- (added and adjusted)
    ]

        \addplot[
            boxplot prepared={
                median=15.5,
                upper quartile=17.6,
                lower whisker=11,
                lower quartile=13.6,
                upper whisker=19,
                whisker extend=0, % height of whiskers
            },
            black,
        ] coordinates {};

    \end{axis}
\end{tikzpicture}
\end{document}

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

관련 정보