
これに似たコードがいくつかあります:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{filecontents}{data-fake.dat}
xpos y date
1 1 09-01
2 3 09-02
3 1 09-03
4 4 09-04
5 2 09-05
6 1 09-06
7 2 09-07
8 0 09-08
9 1 09-09
10 2 09-10
11 1 09-11
12 2 09-12
13 0 09-13
14 1 09-14
15 1 09-15
16 0 09-16
17 2 09-17
18 0 09-18
19 0 09-19
20 0 09-20
21 4 09-21
22 0 09-22
23 0 09-23
24 1 09-24
25 0 09-25
26 0 09-26
27 1 09-27
28 3 09-28
29 1 09-29
30 10 09-30
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=32cm,
axis x line*=bottom,
axis y line*=left,
ymode=log,
log ticks with fixed point,
xtick=data,
xticklabels from table={data-fake.dat}{date},
x tick label style={rotate=90}
]
\addplot table[x=xpos,y=y] {data-fake.dat};
\end{axis}
\end{tikzpicture}
\end{document}
y 軸が対数モードの場合、09-20
プロットは正しく印刷されるのに、x 目盛りが次の 10 目盛りを無視して印刷されるのはなぜですか?
y 軸が対数モードでない場合と同じように、すべての x 目盛りを表示するにはどうすればよいでしょうか?
答え1
問題は、Y 列にゼロ値があり、そのような値の対数が無限大 ( -\infty
) であることです。したがって、そのような値は pgfplots によってスキップされます。3 列目の日付が正しく設定されていません。これは、X 軸の数値 (最初の列) を表示するとわかります。また、そのような値のセット (ゼロを含む) では、対数スケールは使用できません。