我想在 y 轴上添加一些小刻度,但不起作用。我已经尝试了 minor y ticks num,但没有帮助。提前谢谢您。
\documentclass[11pt,a4paper,oneside ]{article}
\usepackage[USenglish, german,ngerman]{babel}
\usepackage[utf8x]{luainputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage[a4paper, top=2cm, bottom=2cm,left=1cm , right =1cm]{geometry}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin = 0,
height=10cm,
width=18cm,
ymode=log,
grid = both,
]
coordinates{
(1,2)(2,4)(3,6)(4,8)(5,10)(6,12)(7,14)(8,16)(9,18)(10,20)
};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
此minor y tick num
键不适用于对数轴(见手册版本 1.10,第 276 页)
但是如果你扩大 y 轴的范围,你就会得到较小的刻度或网格。使用类似的东西enlarge y limits=0.4
来获得
代码:
\documentclass[11pt,a4paper,oneside ]{article}
\usepackage[USenglish, german,ngerman]{babel}
\usepackage[utf8x]{luainputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage[a4paper, top=2cm, bottom=2cm,left=1cm , right =1cm]{geometry}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{pgfplotstable}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin = 0,
height=10cm,
width=18cm,
ymode=log,
grid = both,
major y grid style=red,
enlarge y limits=.4
]
\addplot coordinates{
(1,2)(2,4)(3,6)(4,8)(5,10)(6,12)(7,14)(8,16)(9,18)(10,20)
};
\end{axis}
\end{tikzpicture}
\end{document}
或者,如果您想要小刻度而不是小网格,您可以使用
grid = major,
minor y tick style={red,very thick},
enlarge y limits=.4
或者,您可以设置ymin=1,ymax=100
扩大 y 范围:
grid = major,
minor y tick style={red,very thick},
ymin=1,ymax=100
如果您不想要更大的 y 范围,您可以使用键ytickten={0,...,10}
将主刻度明确设置为 10^0,10^1,...,10^10。那么在您的示例中,10^1 处只有一条主 y 线。
grid = both,
major y grid style=red,
ytickten={0,...,10}
答案2
蜱虫是放置但被网格遮挡。因此,您可以禁用网格,或更改刻度线的样式,使其更加突出:
代码:
\documentclass[11pt,a4paper,oneside ]{article}
\usepackage[USenglish, german,ngerman]{babel}
\usepackage[utf8x]{luainputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage[a4paper, top=2cm, bottom=2cm,left=1cm , right =1cm]{geometry}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin = 0,
height=10cm,
width=18cm,
ymode=log,
grid = both,
y tick style={ultra thick, draw=red},
x tick style={ultra thick, draw=blue},
]
coordinates{
(1,2)(2,4)(3,6)(4,8)(5,10)(6,12)(7,14)(8,16)(9,18)(10,20)
};
\end{axis}
\end{tikzpicture}
\end{document}