无法保存Gnuplot png从c# [英] Unable to save Gnuplot png from within c#

查看:582
本文介绍了无法保存Gnuplot png从c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从c#打开gnuplot,并得到它保存一个图表。有两个问题,有

im trying to open gnuplot from within c# and get it to save a png of a chart. There are 2 issues im having

1)gnuplot的黑色命令行框和实际情节出现。

1) both a black commandline box for gnuplot and the actual plot appear. I would like both of these to not appear.

2)将终端设置为png并绘制sin(x)后,它不会实际保存文件。

2) After setting the terminal to png and plotting sin(x) it doesnt actually save the file. These same commands work within gnuplot though.

感谢


$ b

Thanks

    private void button1_Click(object sender, EventArgs e)
    {
        string Pgm = @"C:\Program Files\gnuplot\bin\gnuplot.exe";
        Process extPro = new Process();
        extPro.StartInfo.FileName = Pgm;
        extPro.StartInfo.UseShellExecute = false;
        extPro.StartInfo.RedirectStandardInput = true;
        extPro.Start();

        StreamWriter gnupStWr = extPro.StandardInput;

        gnupStWr.WriteLine("Set terminal png");
        gnupStWr.WriteLine(@"set output 'c:\Users\FrazMan\Desktop\sinxplot2.png'");
        gnupStWr.WriteLine("plot sin(x)");
        gnupStWr.WriteLine("set terminal wxt enhanced");
        gnupStWr.WriteLine("set output");
        gnupStWr.Flush();
    }

推荐答案

您的脚本为GNUPLOT

seems to me that you could have a problem with your script for the GNUPLOT

尝试更简单

我认为以下脚本应该工作

I think the following script should work

gnupStWr.WriteLine("set terminal png");
gnupStWr.WriteLine(@"set output 'c:\Users\FrazMan\Desktop\sinxplot2.png'");
gnupStWr.WriteLine("plot sin(x)");

尝试避免使用大写字母set terminal png

Try to avoid capital letters for "set terminal png"

我希望它会帮助你

这篇关于无法保存Gnuplot png从c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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