當 y 軸處於對數模式時,x 刻度值被截斷

當 y 軸處於對數模式時,x 刻度值被截斷

我有一些與此類似的程式碼:

\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 軸處於對數模式時,會列印 x 刻度以09-20忽略接下來的 10 個刻度,而繪圖會正確列印?

如果 y 軸未處於對數模式,如何讓所有 x 刻度顯示出來?

在此輸入影像描述

答案1

問題是 Y 列中的值為零,而這些值的對數是無限大 ( -\infty)。因此,pgfplots 會跳過這些值。第三列中的日期設定不正確。如果顯示 X 軸的數值(第一列),就可以看到這一點。對於這樣一組值(帶零),您不能使用對數刻度。

相關內容