如何在 LaTeX 中绘制图表?

发布于 2024-09-04 02:31:12 字数 227 浏览 2 评论 0原文

首先,我要说我正在使用 LyX,尽管我使用 ERT 没有问题。

其次,在 Latex 中绘制这样的简单图形最简单的方法是什么? alt text

我看过一些带有图表的文档,我也看过一些示例,但我不知道如何绘制一个简单的图表 - 我需要什么包,等等?

First of all, let me say I'm using LyX, though I have no problem using ERT.

Secondly, what is the most simplest way to draw a simple graph like this in Latex?
alt text

I've seen some documents with graphs and I've seen some examples, but I couldn't figure out how to just draw a simple graph - what packages do I need, etc?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

放低过去 2024-09-11 02:31:12

TikZ 可以做到这一点。

一个快速演示:

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  [scale=.8,auto=left,every node/.style={circle,fill=blue!20}]
  \node (n6) at (1,10) {6};
  \node (n4) at (4,8)  {4};
  \node (n5) at (8,9)  {5};
  \node (n1) at (11,8) {1};
  \node (n2) at (9,6)  {2};
  \node (n3) at (5,5)  {3};

  \foreach \from/\to in {n6/n4,n4/n5,n5/n1,n1/n2,n2/n5,n2/n3,n3/n4}
    \draw (\from) -- (\to);

\end{tikzpicture}

\end{document}

生成:

在此处输入图像描述

更多示例 @ http://www.texample.net/tikz/examples/tag/graphs/

有关 TikZ 的更多信息:http://sourceforge.net/projects/pgf/ 我想其中也会有安装指南。

TikZ can do this.

A quick demo:

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  [scale=.8,auto=left,every node/.style={circle,fill=blue!20}]
  \node (n6) at (1,10) {6};
  \node (n4) at (4,8)  {4};
  \node (n5) at (8,9)  {5};
  \node (n1) at (11,8) {1};
  \node (n2) at (9,6)  {2};
  \node (n3) at (5,5)  {3};

  \foreach \from/\to in {n6/n4,n4/n5,n5/n1,n1/n2,n2/n5,n2/n3,n3/n4}
    \draw (\from) -- (\to);

\end{tikzpicture}

\end{document}

produces:

enter image description here

More examples @ http://www.texample.net/tikz/examples/tag/graphs/

More information about TikZ: http://sourceforge.net/projects/pgf/ where I guess an installation guide will also be present.

み青杉依旧 2024-09-11 02:31:12

除了使用 TikZ 的(优秀)建议之外,您还可以使用 gastex 。我在 TikZ 可用之前就使用了它,它也完成了它的工作。

Aside from the (excellent) suggestion to use TikZ, you could use gastex. I used this before TikZ was available and it did its job too.

半山落雨半山空 2024-09-11 02:31:12

我已经将 graphviz ( https://www.graphviz.org/gallery ) 与使用点的 LaTeX 一起使用命令生成 PDF 中的图形,并使用 includegraphics 来包含这些图形。

如果 graphviz 产生了您想要的结果,这可能是集成的最佳方式: dot2tex: https: //ctan.org/pkg/dot2tex?lang=en

I have used graphviz ( https://www.graphviz.org/gallery ) together with LaTeX using dot command to generate graphs in PDF and includegraphics to include those.

If graphviz produces what you are aiming at, this might be the best way to integrate: dot2tex: https://ctan.org/pkg/dot2tex?lang=en

鸩远一方 2024-09-11 02:31:12

也许使用 tikz

Perhaps use tikz.

陈甜 2024-09-11 02:31:12

根据我的经验,我总是使用外部程序来生成图形(mathematica、gnuplot、matlab 等)并将图形导出为 pdf 或 eps 文件。然后我使用 includegraphics 将其包含到文档中。

In my experience, I always just use an external program to generate the graph (mathematica, gnuplot, matlab, etc.) and export the graph as a pdf or eps file. Then I include it into the document with includegraphics.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文