*绘制* std::vector的简单/最简单的方法是什么?
我正在寻找类似的东西:
std::vector<double> X = some_math_function( );
somenamespace :: plot( Wrapper( X ) ); // pop-up and display a graph of X on y-axis, 1 to X.size() on x-axis.
显然有更重量级的方法,例如设置 gnu-plot 或其他什么,并且我已经在 VTK 图表中使用了这些内容。我只是想让一个愚蠢的、贫民窟的情节出现。这是为了进行粗略的调试检查,例如“矢量是否在变化?当我移动相机时它是否突然抖动?”等等。
I'm looking for something like:
std::vector<double> X = some_math_function( );
somenamespace :: plot( Wrapper( X ) ); // pop-up and display a graph of X on y-axis, 1 to X.size() on x-axis.
Obviously there are heavier-weight methods like setting up gnu-plot or whatever, and I've used the stuff in VTK charts. I just want a stupid, ghetto, plot to appear. This is for coarse debug checking things like "is the vector even changing? does it suddenly jerk when I move the camera?" and so on.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果这是为了调试,为什么不将向量输出到分隔文件并在 excel 或 gnuplot 或其他内容中作为单独的步骤进行绘图?
所以就像
然后只需在您喜欢的工具中绘制文件即可,例如
If this is for debugging why not just output the vector to a delimited file and plot in excel or gnuplot or something as a separate step?
so something like
then just plot the file in what ever tool you like e.g.
这个帖子似乎对此事有很多建议。我还没有看到任何能够满足您想要的目的的简单库。
这里有一些轻量级的例子,但在我看来,如果你必须学习足够的知识来支持任何库,你也可以支持像 gnuplot 这样受人尊敬的库。在许多情况下,您因处理更复杂的库而损失的时间可以通过社区支持和(相对)无错误......更成熟的产品来弥补。
koolplot
妖精
This thread seems to have quite a few suggestions on the matter. I haven't seen anything that stands out as a simple library for the purposes you want.
Here are a few lightweight examples, but it seems to me that if you've got to learn enough to stand up any library, you may as well stand up a respected one like gnuplot. In many cases the time you lose by having to deal with a more complex library is more than made up for by the community support and (relative) bugless..ness... of a more mature product.
koolplot
GOBLIN
您可以使用 MathGL (跨平台 GPL 绘图库)。代码看起来像
You can use MathGL (cross-platform GPL plotting library). The code look as
使用 C++11:我建议使用 matplotlibcpp 它使用 python 进行绘图。该库使用起来非常简单,您只需将头文件复制到存储库中即可。
代码如下所示:
在您的
cmake
中:或者将其直接传递给您的编译器:
Using C++11: I would recommend using matplotlibcpp which uses python for plots. The library is REALLY straightforward to use and you only need to copy the header file in your repository.
The code would looks like:
In your
cmake
:Or pass it to directly to your compiler:
我记得在 php 中使用 gd 很容易绘制曲线,但那是很久以前的事了。
I remember being easy to plot curves with gd in php, but that was a long time ago.