如何绘制C ++ Win32控制台应用程序的输出?

时间:2022-05-18 20:45:25

I have a small Win32 console application which is essentially a test harness. I read data in, do some processing on it and currently just output some of the numbers to the console. This isn't a huge problem - I can get an idea of what the data looks like, but it would be much easier to analyse if there was a way of getting that information into a graph for each run of the software.

我有一个小的Win32控制台应用程序,它本质上是一个测试工具。我读取数据,对其进行一些处理,目前只是将一些数字输出到控制台。这不是一个大问题 - 我可以了解数据的样子,但是如果有一种方法可以将信息转换为每次运行软件的图表,那么分析会更容易。

I've been getting to grips with GNUPlot recently, but can't work out a simple way to get the data sent to it. Has anyone tried this? ..or is there another graphing application I should try?

我最近一直在处理GNUPlot,但无法找到一种简单的方法来获取发送给它的数据。有没人试过这个? ..或者我应该尝试另一个图形应用程序吗?

Excel and OO Calc are great tools and I've loaded .csv data into them for graphing data plenty of times myself. I was, however, hoping for a way to dynamically pipe data into a graphing application to avoid having to close/reopen excel and plot a graph each time I want to look at some data.

Excel和OO Calc是很棒的工具,我已经将.csv数据加载到它们中,以便自己多次绘制数据。然而,我希望有一种方法可以动态地将数据传输到图形应用程序中,以避免每次我想要查看某些数据时关闭/重新打开excel并绘制图形。

I think you can pipe data into GNUPlot (which is why I mentioned it) but the details of how to do so are rather scant.

我认为你可以将数据传输到GNUPlot(这就是为什么我提到它),但是如何这样做的细节相当少。

7 个解决方案

#1


You don't really need to touch VBA to do this

你真的不需要触摸VBA来做到这一点

In Excel you can set up a Data Connection to a file, it supports many files type but CSV does work fine.

在Excel中,您可以设置与文件的数据连接,它支持许多文件类型,但CSV可以正常工作。

  • Go to List item
  • 转到列表项

  • Data Tab
  • Click Connections
  • Click Add
  • select the file
  • 选择文件

  • go to the connection properties - un-tick prompt for file name
  • 转到连接属性 - 取消选中文件名的提示

  • set the required period.
  • 设置所需的时间段。

  • close the connections dialog
  • 关闭连接对话框

  • select the start cell for importing the data - cell 1a on worksheet 2
  • 选择用于导入数据的起始单元格 - 工作表2上的单元格1a

  • click existing connections
  • 单击现有连接

  • select you data connection
  • 选择你的数据连接

  • flip to worksheet1 add your chart and hookup the data.
  • 翻转到工作表1添加图表并连接数据。

the chart will now update automatically

图表现在将自动更新

this is Excel 2007 - but think older version had this and I think OO can do it to.

这是Excel 2007 - 但是认为旧版本有这个,我认为OO可以做到这一点。

#2


A simple approach is to wtite the data out as CSV and then import it into a spreadsheet like Excel or OpenOffice to do the graph drawing.

一种简单的方法是将数据作为CSV重新输入,然后将其导入Excel或OpenOffice等电子表格中以进行图形绘制。

Edit: Following your question, I got interested in GNUPlot myself - this is the simplest description of using it from the command line that I found: http://www.goldb.org/goldblog/CommentView,guid,f378e279-eaa5-4d85-b7d2-0339a7c72864.aspx

编辑:在你的问题之后,我自己对GNUPlot感兴趣 - 这是我在命令行中使用它的最简单描述:http://www.goldb.org/goldblog/CommentView,guid,f378e279-eaa5-4d85 -b7d2-0339a7c72864.aspx

#3


Never underestimate the power of Excel and a .csv data dump.

永远不要低估Excel和.csv数据转储的强大功能。

Writing data to a .csv file form C++ is not very difficult and there's lots of articles out there regarding the subject, for example: here, or just google.

将数据写入.csv文件形式C ++并不是很困难,并且有很多关于该主题的文章,例如:在这里,或者只是谷歌。

Excel can easily load .csv's and then you can just use that to plot whatever graphs you require. THis is particularly useful if you just want a quick visual sanity check of results etc.

Excel可以轻松加载.csv,然后您可以使用它来绘制您需要的任何图形。如果您只想对结果进行快速视觉检查等,这一点特别有用。

#4


You might also want to look into XMGrace which allows you to launch it and drive it dircetly from C/Fortran programs as shown here

您可能还想查看XMGrace,它允许您启动它并从C / Fortran程序中直接驱动它,如此处所示

#5


Excel is completely script-able. Use the macro recorder to figure out the steps. Create the chart in its own sheet. Then save the chart using the GIF filter.

Excel完全可以编写脚本。使用宏录制器找出步骤。在自己的工作表中创建图表。然后使用GIF过滤器保存图表。

The actual import is something like:

实际导入类似于:

ActiveChart.Export FileName:=something_dot_gif, FilterName:="GIF"

ActiveChart.Export FileName:= something_dot_gif,FilterName:=“GIF”

#6


I just found an example of piping data into gnuplot on Cardiff University's website. Not tried it yet, but it looks promising!

我刚刚在卡迪夫大学的网站上找到了将数据传输到gnuplot的示例。尚未尝试过,但看起来很有前途!

[edit] ..and another which includes some notes for windows.

[编辑] ..和另一个包括一些窗口的笔记。

#7


You can use MathGL - it can create a window (FLTK, GLUT or Qt) and display plot inside. Also it have large set of plot types and can work in console.

您可以使用MathGL - 它可以创建一个窗口(FLTK,GLUT或Qt)并在里面显示绘图。它还有大量的绘图类型,可以在控制台中工作。

#1


You don't really need to touch VBA to do this

你真的不需要触摸VBA来做到这一点

In Excel you can set up a Data Connection to a file, it supports many files type but CSV does work fine.

在Excel中,您可以设置与文件的数据连接,它支持许多文件类型,但CSV可以正常工作。

  • Go to List item
  • 转到列表项

  • Data Tab
  • Click Connections
  • Click Add
  • select the file
  • 选择文件

  • go to the connection properties - un-tick prompt for file name
  • 转到连接属性 - 取消选中文件名的提示

  • set the required period.
  • 设置所需的时间段。

  • close the connections dialog
  • 关闭连接对话框

  • select the start cell for importing the data - cell 1a on worksheet 2
  • 选择用于导入数据的起始单元格 - 工作表2上的单元格1a

  • click existing connections
  • 单击现有连接

  • select you data connection
  • 选择你的数据连接

  • flip to worksheet1 add your chart and hookup the data.
  • 翻转到工作表1添加图表并连接数据。

the chart will now update automatically

图表现在将自动更新

this is Excel 2007 - but think older version had this and I think OO can do it to.

这是Excel 2007 - 但是认为旧版本有这个,我认为OO可以做到这一点。

#2


A simple approach is to wtite the data out as CSV and then import it into a spreadsheet like Excel or OpenOffice to do the graph drawing.

一种简单的方法是将数据作为CSV重新输入,然后将其导入Excel或OpenOffice等电子表格中以进行图形绘制。

Edit: Following your question, I got interested in GNUPlot myself - this is the simplest description of using it from the command line that I found: http://www.goldb.org/goldblog/CommentView,guid,f378e279-eaa5-4d85-b7d2-0339a7c72864.aspx

编辑:在你的问题之后,我自己对GNUPlot感兴趣 - 这是我在命令行中使用它的最简单描述:http://www.goldb.org/goldblog/CommentView,guid,f378e279-eaa5-4d85 -b7d2-0339a7c72864.aspx

#3


Never underestimate the power of Excel and a .csv data dump.

永远不要低估Excel和.csv数据转储的强大功能。

Writing data to a .csv file form C++ is not very difficult and there's lots of articles out there regarding the subject, for example: here, or just google.

将数据写入.csv文件形式C ++并不是很困难,并且有很多关于该主题的文章,例如:在这里,或者只是谷歌。

Excel can easily load .csv's and then you can just use that to plot whatever graphs you require. THis is particularly useful if you just want a quick visual sanity check of results etc.

Excel可以轻松加载.csv,然后您可以使用它来绘制您需要的任何图形。如果您只想对结果进行快速视觉检查等,这一点特别有用。

#4


You might also want to look into XMGrace which allows you to launch it and drive it dircetly from C/Fortran programs as shown here

您可能还想查看XMGrace,它允许您启动它并从C / Fortran程序中直接驱动它,如此处所示

#5


Excel is completely script-able. Use the macro recorder to figure out the steps. Create the chart in its own sheet. Then save the chart using the GIF filter.

Excel完全可以编写脚本。使用宏录制器找出步骤。在自己的工作表中创建图表。然后使用GIF过滤器保存图表。

The actual import is something like:

实际导入类似于:

ActiveChart.Export FileName:=something_dot_gif, FilterName:="GIF"

ActiveChart.Export FileName:= something_dot_gif,FilterName:=“GIF”

#6


I just found an example of piping data into gnuplot on Cardiff University's website. Not tried it yet, but it looks promising!

我刚刚在卡迪夫大学的网站上找到了将数据传输到gnuplot的示例。尚未尝试过,但看起来很有前途!

[edit] ..and another which includes some notes for windows.

[编辑] ..和另一个包括一些窗口的笔记。

#7


You can use MathGL - it can create a window (FLTK, GLUT or Qt) and display plot inside. Also it have large set of plot types and can work in console.

您可以使用MathGL - 它可以创建一个窗口(FLTK,GLUT或Qt)并在里面显示绘图。它还有大量的绘图类型,可以在控制台中工作。