如何去除 pgfplots 頂部的小刻度

如何去除 pgfplots 頂部的小刻度

我正在尋找一種方法來消除圖形頂部的小刻度(灰色的小刻度),但保持它們沿著 x 軸完好無損?我的程式碼如下:

\begin{figure}[h]
\caption{Distribution of visitor}
\label{DistributionFirmVisitors}
\begin{center}
\begin{tikzpicture}
\begin{axis}[width=10cm,height=7cm,
ylabel={\% of EDGAR visitors},
xmin=1, 
xmax=200,
ymin=0.3, 
ymax=1,
xtick={1, 25, 50, 75, 100, 125, 150, 175, 200},
ytick={0.3,0.4,0.5,0.6,0.7,0.8,0.9,1},
xticklabel style={/pgf/number format/1000 sep=,rotate=60,anchor=east,font=\normalsize},
tick label style={/pgf/number
format/precision=5},
scaled y ticks = false,
legend pos=north east,
ymajorgrids=true,
grid style=dashed,
every axis plot/.append style={thick},
axis background/.style={fill=gray!5},
] 

\addplot[
color=black,
]
coordinates {

(1, 0.1)
(25, 0.1)
(50,0.1)
(75,0.1)    
(100,   0.1)
(200,   0.1)

};


\end{axis}
\end{tikzpicture} \\
\end{center}
\end{figure} \vspace{0.4cm}

答案1

我猜你正在尋找xtick pos=lower.

% used PGFPlots v1.16
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{compat=1.3}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        width=10cm,
        height=7cm,
        ylabel={\% of EDGAR visitors},
        xmin=1,
        xmax=200,
        ymin=0.3,
        ymax=1,
        xtick={1, 25, 50, 75, 100, 125, 150, 175, 200},
        ytick={0.3,0.4,0.5,0.6,0.7,0.8,0.9,1},
        xticklabel style={
            rotate=60,
            anchor=east,
            font=\normalsize,
        },
        ymajorgrids=true,
        grid style=dashed,
        axis background/.style={fill=gray!5},
        xtick pos=lower,    % <-- added
    ]

        % (because of y = 0.1 and `ymin=0.3` it is invisible anyway)
        \addplot coordinates {(1,0.1)};

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

顯示上述程式碼結果的圖像

相關內容