C ++和gnuplot [英] C++ and gnuplot

查看:74
本文介绍了C ++和gnuplot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一篇文章,我是C ++和一般编译的新手.

This is my first post and I'm quite a novice on C++ and compiling in general.

我正在编译一个程序,该程序需要绘制一些图形.该程序创建一个 .dat文件,然后我应该打开gnuplot并编写图' .dat.很好.

I'm compiling a program which requires some graphs to be drawn. The program create a .dat file and then i should open gnuplot and write plot '.dat'. That's fine.

有没有一种方法可以使gnuplot自动打开并向我显示所需的图?我应该在代码中使用一些system()函数来调用gnuplot,但是如何让他绘制所需的内容?

Is there a way to make gnuplot automatically open and show me the plot I need? I should use some system() function in the code to call gnuplot but how can I make him plot what I need?

对不起,我的英语不完美:s

Sorry for my non-perfect English :s

仍然感谢您的关注!

推荐答案

根据您的操作系统,您可能可以使用

Depending on your OS, you might be able to use popen(). This would let you spawn a gnuplot process and just just write to it like any other FILE*.

如果要绘制数据点,则可以使用 plot-" ... 选项将它们内联传递.同样,您可能想探索设置数据样式点/线/linespoints/etc 选项.

If you have datapoints to plot, you can pass them inline with the plot "-" ... option. Similarly, you may want to explore set data style points/lines/linespoints/etc options.

在没有暂停或持续的情况下,gnuplot将在输入流结束时终止.在您的示例情况下,就是到达文件末尾的时候.

Without pause or persist, gnuplot will terminate upon end-of-input-stream. In your example case, that would be when the end of the file is reached.

要生成(写入)输出文件(图形),请使用:

To produce (write) an output file (graph), use:

set terminal png small
set output "filename.png"

设置终端有很多选项. Png通常在那里.如果不是,也许是gif,tiff或jpeg?

There's lots of options to set terminal. Png is usually there. If not, perhaps gif, tiff, or jpeg?

当心覆盖文件!

您可能要使用设置大小2,2 来制作更大的图形.某些 set终端变体还允许您指定大小.

You may want to use set size 2,2 to make a larger graph. Some set terminal variants also allow you to specify the size.

这篇关于C ++和gnuplot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆