我想使用 TikZ 绘制以下图像:
如何使用 TikZ 生成具有对数缩放的 X 轴?对于线性缩放,我使用此代码:
\usetikzlibrary{plotmarks}
%axis
\draw (3,0) -- coordinate (x axis mid) (21,0);
%ticks
\foreach \x in {3,...,21}
\draw (\x,0pt) -- (\x,-3pt)
node[anchor=north] {\x};
%labels
\node[below=0.8cm] at (x axis mid) {Physical dose [Gy]};
答案1
这看起来像是 PGFPlots 的工作:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
y=1.5cm, % y unit vector
hide y axis, % hide the y axis
xmode = log, % logarithmic x axis
axis x line*=bottom,% only show the bottom x axis line, without an arrow tip
xmin=1e-4, xmax=1e2,% range for the x axis
xlabel = Dose in Sv
]
\addplot [no markers, line width=6pt] table {
0.002 1
0.004 1
};
\end{axis}
\end{tikzpicture}
\end{document}
答案2
这应该不是正确的做法。请随意编辑!
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\def\f[#1,#2]{!#1 log 4 add #2 8 div}
\begin{document}
\pspicture(0,-0.25)(6,0.125)
\psaxes
[
yAxis=false,
subticks=9,
xlogBase=10,
Ox=-4,
logLines=x,
ticksize=-1.5pt 1.5pt,
](6,0.125)
\psline[linewidth=2\pslinewidth](\f[0.002,1])(\f[0.004,1])
\endpspicture
\end{document}