我正在寻找一种方法来去除图形顶部的小刻度(小灰色刻度),但保持它们沿 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}