我正在绘制一个条形图,并且 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}