![如何修复轴上功率 (10^x) 的外观,使其接近或在 x 轴上](https://linux22.com/image/454472/%E5%A6%82%E4%BD%95%E4%BF%AE%E5%A4%8D%E8%BD%B4%E4%B8%8A%E5%8A%9F%E7%8E%87%20(10%5Ex)%20%E7%9A%84%E5%A4%96%E8%A7%82%EF%BC%8C%E4%BD%BF%E5%85%B6%E6%8E%A5%E8%BF%91%E6%88%96%E5%9C%A8%20x%20%E8%BD%B4%E4%B8%8A.png)
我正在绘制一个条形图,并且 x 轴处的功率 (10^x) 距离轴很远,如下图所示:
我使用以下代码绘制该图:\pgfplotstableread{datahis.dat}\loadedtable
\begin{tikzpicture}[scale = 1]
\begin{axis}[ybar,
ybar interval = 1,
mark = none,
draw = none,
xtick={ 2e6,4e6, 6e6,8e6, 10e6},
ytick={ 2e+3,4e+3,6e+3,8e+3,10e+3, 12e+3 },
xmax =10.199969990000000000e+06,
enlargelimits=0.05,
grid = none,
ylabel = {{\small Raw Events}},
xlabel = {{\small Time ($\mu$s)}},
tick align=inside,
tickpos=left,
every axis plot post/.append style=
{mark=none},
legend columns=-1,
area style,
bar width = 0.6
]
\addplot +[ybar, draw=blue,fill=black!30!white, mark = none] table[x= edges,
y=bins] from \loadedtable;
\addplot[red,sharp plot,update limits=false]
coordinates {(7.866602500000000000e+05, 200) (9.086350000000000000e+06,200)}
node[above] at (axis cs:7.8407000000000000e+06,270) {\footnotesize{Threshold
rate}};
\end{axis}
\end{tikzpicture}
有人可以建议如何解决这个问题吗?
谢谢。
答案1
人们通常会将small
选项添加到小图表的轴上,但您也可以像这样将乘数向上移动:
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=5cm,
xmin=0, xmax=10e6,
ymin=0, ymax=12e+3,
xtick={2e6,4e6, 6e6,8e6,10e6},
ytick={2e+3,4e+3,6e+3,8e+3,10e+3,12e+3},
xmax =10e+06,
enlargelimits=0.05,
ylabel={\small Raw Events},
xlabel={\small Time ($\mu$s)},
tick align=inside,
tickpos=left,
x tick scale label style={yshift=4pt},
]
\end{axis}
\end{tikzpicture}
\end{document}