gpt4 book ai didi

LaTeX 条形图

转载 作者:行者123 更新时间:2023-12-01 08:39:43 28 4
gpt4 key购买 nike

我正在尝试使用 LaTeX 制作条形图。到目前为止我一直不成功,所以任何人都可以帮助我,也许是最近项目的副本?如何使用 pstricks 制作条形图?我会很感激最简单的解决方案,因为我最近才开始使用 TeX。

Like mentioned here in the official document

这是我目前所拥有的:

\psset{unit=0.5in}%
\begin{pspicture}(0,-0.5)(3,3)%
\readpsbardata{\data}{example1.csv}%
\psbarchart[barstyle={red,blue}]{\data}%
\end{pspicture}

最佳答案

我强烈推荐使用 PGF、TiKZ 和 PGFPlots 的神奇组合。这些工具被普遍接受为 pstricks 的替代品。它们与 pdflatex 和许多其他会给 pstricks 带来麻烦的工具兼容。

下面这个高度语义化的 TeX 源码

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.4}

\begin{document}

\begin{tikzpicture}

\begin{axis}[%
scale only axis,
width=5in,
height=4in,
xmin=-3, xmax=3,
ymin=0, ymax=1,
axis on top]
\addplot[
ybar,
bar width=0.102874in,
bar shift=0in,
fill=red,
draw=black]
plot coordinates{
(-2.9,0.00022263) (-2.7,0.000682328) (-2.5,0.00193045) (-2.3,0.00504176)
(-2.1,0.0121552) (-1.9,0.0270518) (-1.7,0.0555762) (-1.5,0.105399)
(-1.3,0.18452) (-1.1,0.298197) (-0.9,0.444858) (-0.7,0.612626)
(-0.5,0.778801) (-0.3,0.913931) (-0.1,0.99005) (0.1,0.99005)
(0.3,0.913931) (0.5,0.778801) (0.7,0.612626) (0.9,0.444858)
(1.1,0.298197) (1.3,0.18452) (1.5,0.105399) (1.7,0.0555762)
(1.9,0.0270518) (2.1,0.0121552) (2.3,0.00504176) (2.5,0.00193045)
(2.7,0.000682328) (2.9,0.00022263)
};

\end{axis}
\end{tikzpicture}

\end{document}

产量

Bar graph example

关于LaTeX 条形图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4902147/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com