【问题标题】:Writing small numbers in Latex figures在 Latex 图形中写入小数字
【发布时间】:2023-02-16 00:09:48
【问题描述】:

我有一个基本图形,我希望以下数字位于 Y 轴上 0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1

当我在代码中编写它们时,它们的显示方式与您在屏幕截图中看到的不同。 我知道这在数学上是正确的,但它们看起来很奇怪,我希望它们能完全按照我在代码中放置的方式显示。

这是代码

\documentclass{article}
\usepackage{graphicx} % Required for inserting images

\usepackage{pgfplots}
\begin{document}

\begin{figure} 
\centering
\begin{tikzpicture} [style={outer sep=5}]
\begin{axis}[ymin=0,ymax=0.1, xmin=15, xmax=50,
xtick={15,20,...,50},
ytick={0,0.01,...,0.1},
grid={major},clip=false,grid style={dashed},
title={},
legend style={at={(1.2 ,1)},anchor=north},
font=\footnotesize]

% 25
\addplot[color=green, mark=*, samples=10] [error bars/.cd,y dir=both, y explicit] coordinates {
(15, 0.0032)
(20, 0.0039) 
(25, 0.0052) 
(30, 0.007)
(35, 0.009)
(40, 0.0095) 
(45, 0.01)
(50, 0.012)
};


\end{axis}
\end{tikzpicture}
\caption[]{}
\end{figure}

\end{document}

【问题讨论】:

  • 请制作一个可编译的minimal reproducible example,包括所有必要的包等。
  • 无关:对$TAODV$等使用数学模式不是一个好主意。这会弄乱字母之间的所有字距调整。只要看看 T 和 A 之间的宽阔空间以及 D 几乎接触到 V...
  • 我用来创建图形的包是 pgfplots
  • 您应该编辑您的问题以提供一个单一的可编译代码块,我们可以复制并粘贴该代码块以重新创建您的问题。
  • 我已经更新了代码。现在您可以复制并粘贴它,它就会起作用。谢谢。

标签: latex


【解决方案1】:

您可以使用yticklabel style={/pgf/number format/fixed} 更改数字格式:

documentclass{article}
usepackage{graphicx} % Required for inserting images

usepackage{pgfplots}
egin{document}

egin{figure} 
centering
egin{tikzpicture} [style={outer sep=5}]
egin{axis}[ymin=0,ymax=0.1, xmin=15, xmax=50,
xtick={15,20,...,50},
ytick={0,0.01,...,0.1},
grid={major},clip=false,grid style={dashed},
title={},
legend style={at={(1.2 ,1)},anchor=north},
font=ootnotesize,
scaled y ticks=false,
yticklabel style={/pgf/number format/fixed},
]

% 25
ddplot[color=green, mark=*, samples=10] [error bars/.cd,y dir=both, y explicit] coordinates {
(15, 0.0032)
(20, 0.0039) 
(25, 0.0052) 
(30, 0.007)
(35, 0.009)
(40, 0.0095) 
(45, 0.01)
(50, 0.012)
};


end{axis}
end{tikzpicture}
caption[]{}
end{figure}

end{document}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-28
    • 1970-01-01
    相关资源
    最近更新 更多