C++ 中的散点图

发布于 2024-07-07 03:55:35 字数 1560 浏览 6 评论 0原文

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

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

发布评论

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

评论(9

在风中等你 2024-07-14 03:55:35

我总是写出数据,然后使用 gnuplot 创建图表。 这是迄今为止我发现的以各种格式生成图表的最佳方法:eps、png、jpeg、xpm,凡是你能想到的格式。

gnuplot 将非常容易地绘制散点图。 假设 x 和 y 值位于 2 个以空格分隔的列中,那么

plot "data.txt" using 1:2 

将为您提供快速散点图。 然后你可以调整它以及不使用其他 gnuplot 命令的内容。

如果您从事科学工作,那么学习 gnuplot 对您来说非常有价值。 它确实让制作 Excel 绘图变得一团糟,并且简化了制作包含在论文中的绘图的任务。

I always write out data and then using gnuplot to create my graphs. It is by far the best way I have found of producing graphs in a variety of formats: eps, png, jpeg, xpm, you name it.

gnuplot will do scatter plot very easily. Provided the x and y values are in 2 space-separated columnss, then

plot "data.txt" using 1:2 

Will give you a quick scatter plot. Then you can adjust it and what not using other gnuplot commands.

If you are involved in sciences, then learning gnuplot will be very valuable to you. It kicks the crap out of doing excel plots for sure and it eases the task of making plots to include in papers.

浪漫人生路 2024-07-14 03:55:35

如果您正在寻找 C++ 库而不是像 gnuplot 这样的独立绘图工具,我会考虑以下内容:

dislin 似乎是两者中更有趣的一个。 以下是从维基百科文章中摘录的描述:

DISLIN 是一个高级且易于使用的绘图库,由德国卡特伦堡-林道马克斯普朗克研究所的 Helmut Michels 开发。 Helmut Michels 目前在该研究所的计算机中心担任数学家和 Unix 系统管理员。

DISLIN 库包含用于将数据显示为曲线、条形图、饼图、3D 彩色图、曲面、等高线和地图的例程和函数。 支持多种输出格式,例如 X11、VGA、PostScript、PDF、CGM、HPGL、SVG、PNG、BMP、PPM、GIF 和 TIFF。

DISLIN 可用于编程语言 Fortran 77、Fortran 90/95 和 C。大多数操作系统还支持 Perl、Python 和 Java 语言的绘图扩展。 DISLIN的当前版本是9.4,于2008年10月发布。第一个版本1.0于1986年12月发布。

DISLIN 软件可免费用于非商业用途。

If you are looking for a C++ library rather than I independent plotting tool like gnuplot, I would consider the following:

dislin seems to be the more interesting of the two. Here is a description extracted from the wikipedia article:

DISLIN is a high-level and easy to use plotting library developed by Helmut Michels at the Max Planck Institute in Katlenburg-Lindau, Germany. Helmut Michels currently works as a mathematician and Unix system manager at the computer center of the institute.

The DISLIN library contains routines and functions for displaying data as curves, bar graphs, pie charts, 3D-colour plots, surfaces, contours and maps. Several output formats are supported such as X11, VGA, PostScript, PDF, CGM, HPGL, SVG, PNG, BMP, PPM, GIF and TIFF.

DISLIN is available for the programming languages Fortran 77, Fortran 90/95 and C. Plotting extensions for the languages Perl, Python and Java are also supported for most operating systems. The current version of DISLIN is 9.4, released in October 2008. The first version 1.0 was released in December 1986.

The DISLIN software is free for non-commercial use.

一个人的夜不怕黑 2024-07-14 03:55:35

非常重的解决方案:您可以链接到 ROOT,它将执行您想要的任何操作:

  • 在 Mac、Windows 上运行Linux
  • 运行编译或使用 cint interperter
  • 输出到封装的 postscript、PDF、gif、png 中的文件...
  • 使用几种不同的技术在屏幕上显示以
  • 稍后可以操作的内部格式序列化数据

当然,它有点对于大多数人来说很多,但它确实满足了您的要求。 我使用它是因为我知道它并且它已经在我的机器上,因为我是那种物理学家。

Very heavy solution: you could link against ROOT, which will do just about anything you want:

  • runs on Mac, Windows and Linux
  • runs compiled or using the cint interperter
  • output to a file in encapsulated postscript, PDF, gif, png...
  • display to the screen using several different technologies
  • serialize the data in an internal format that can be manipulated later

Sure, its a bit much for most people, but it does do exactly what you asked for. I use it because I know it and it is already on my machines becase I'm that kind of physicist.

不弃不离 2024-07-14 03:55:35

好老的 GNU,他们拥有一切......

http://directory.fsf.org/project/plotutils/

Good old GNU, they have everything...

http://directory.fsf.org/project/plotutils/

Oo萌小芽oO 2024-07-14 03:55:35

这当然不是最好的方法,但我通常编写可由 R 读取的输出文件并使用这与适当的脚本一起绘制图表。

This is certainly not the best way but I usually write output files that can be read by R and use this, along with an appropriate script, to plot the graphs.

转身以后 2024-07-14 03:55:35

这里的问题是,C++ 与 Java 不同,没有内置的 GUI 或图形。 如果您想使用 C++ 生成图形,您需要使用适用于您的操作系统的 GUI 库。 有免费的 GUI 库,许多跨平台的,例如 Qt 或 GTK。

然而,正如其他人指出的那样,最简单的方法是将数据保存到文本文件中,然后使用另一个程序生成图表。 gnuplot 绝对是一个不错的选择。 它是大多数 Linux 发行版的标准配置,您也可以在 cygwin 下获得 Windows 版本。

The problem here is that C++, unlike Java for example, does not have built-in GUI or graphics. If you want to generate graphs with C++ you would need to use a GUI library available for your OS. There are free GUI libraries, many cross-plaform such as Qt or GTK.

However, as other people have pointed out, the easiest thing for you to do would be to save the data into a text file, and use another program to generate the graph. gnuplot is definitely a good choice. It comes standard with most linux distros, and you get for Windows under cygwin.

各自安好 2024-07-14 03:55:35

向那些尚未使用 C++ 进行绘图的人致敬。 我会说我是如何用 C++ 绘制图形的

  1. http://sourceforge.jp/projects/sfnet_gnuplot/downloads/gnuplot/4.4.3/gp443win32.zip/

  2. 将其解压到“C:\Gnuplot”中
    然后我读了“C:\Gnuplot\gnuplot\README.Windows”
    我得到了这些信息:

  3. 我使用的是 Windows 7 ==> 所以你需要下载“winhlp32.exe”...只需在搜索引擎中搜索“winhlp32.exe Windows 7”并浏览第一个链接。

  4. 将二进制文件夹的路径附加到“Path”环境变量,即“C:\Gnuplot\gnuplot\binary”

  5. 然后我关闭计算机并再次打开它。 当我发现它没有感觉到环境变量的变化:D

  6. 你现在需要编写一个示例代码来测试你的绘图能力:)
    所以你可以访问这个链接
    http://code.google.com/p/gnuplot -cpp/source/browse/#svn%2Ftrunk
    查看头文件“gnuplot_i.hpp”和源文件“example.cc”。

您将获得很多很多图表,选择合适的图表,定制您的核心,然后享受:)

Regards plotting in C++ for anyone who didn't do it yet. I will say what I did to plot Graphs in C++

  1. Download the zipped file "gp443win32.zip" from http://sourceforge.jp/projects/sfnet_gnuplot/downloads/gnuplot/4.4.3/gp443win32.zip/

  2. Extract it in "C:\Gnuplot"
    then I read "C:\Gnuplot\gnuplot\README.Windows"
    and I got these information:

  3. I used Windows 7 ==> so you need to download "winhlp32.exe"... just search for it "winhlp32.exe Windows 7" in a search engine and go through the first link.

  4. Append to the "Path" Environment variable the path for binary folder which is "C:\Gnuplot\gnuplot\binary"

  5. then I shutdown my computer and open it again. After I found that it didn't sense the change in the environment variables :D

  6. you need now to write a sample code to test your plotting ability :)
    so you can visit this link
    http://code.google.com/p/gnuplot-cpp/source/browse/#svn%2Ftrunk
    to see the header file "gnuplot_i.hpp" and source file "example.cc".

You will get many and many graphs, choose your appropriate graph, customize your core, and enjoy :)

无戏配角 2024-07-14 03:55:35

如果您熟悉 matplotlib,则可以在 C/C++ 中嵌入 python应用程序。 根据您的需要,这可能是一个快速的解决方案。

If you're familiar with matplotlib, you can embed python in C/C++ applications. Depending on what you want it for, this might be a quick solution.

故人如初 2024-07-14 03:55:35

Chart Director 具有 C++ 绑定。 我使用过他们的 .Net 库,并且对它们非常满意。 这是一个非常便宜的库,并且使您能够制作各种不同的图表。

Chart Director has bindings for C++. I've used their .Net libraries, and I've been pretty happy with them. It's a pretty cheap library, and gives you the power to do all sorts of different charts.

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