![用大数字绘制点](https://linux22.com/image/398498/%E7%94%A8%E5%A4%A7%E6%95%B0%E5%AD%97%E7%BB%98%E5%88%B6%E7%82%B9.png)
我正在尝试绘制这个图:
y 轴上的数字非常大,并引发错误:
! Dimension too large
。另一个问题是xtick
标记消失。在下面的代码中,必须改进什么?
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=1.2]
\begin{axis}[%
,axis line style = thick
,domain=1810:2020
,axis lines=middle
,enlargelimits=true
,xtick={1814,1900,1950,1968,2000,2014}
,ytick={10,100,1000,10000,100000,1000000},
]
\addplot [only marks] table {
1814,7
1905,8
1905,10
1930,7
1938,12
1942,16
1956,16
1958,64
1958,96
1963,10
1966,200
1966,512
1968,50
1978,256
1979,48
1982,640
1990,32
1993,32
1996,8000
1996,8000
1999,200
2003,2048
2003,16384
2005,12288
2007,1000000
2012,100000000
2013,1000000
2014,100000000
};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
答案1
在删除隐藏字符(Zarko 也指出了这一点)并添加 之后col sep=comma
,我没有收到任何dimension too large
错误。但是,为了使代码更类似于目标输出,您可能需要使用ymode=log
,并旋转 xtick 标签以避免重叠。我axis lines
还将middle
改为left
。
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16,width=12cm}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[ymode=log,
,axis line style = thick
,domain=1810:2020
,axis lines=left
,enlargelimits=true
,xtick={1814,1900,1950,1968,2000,2014}
,xticklabel style={rotate=45},
,ytick={10,100,1000,10000,100000,1000000,10000000,100000000},
/pgf/number format/set thousands separator={}
]
\addplot [only marks] table[col sep=comma] {
1814,7
1905,8
1905,10
1930,7
1938,12
1942,16
1956,16
1958,64
1958,96
1963,10
1966,200
1966,512
1968,50
1978,256
1979,48
1982,640
1990,32
1993,32
1996,8000
1996,8000
1999,200
2003,2048
2003,16384
2005,12288
2007,1000000
2012,100000000
2013,1000000
2014,100000000
};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}