gnuplot-cpp library使用记录

static void set_terminal_std(const std::string &type);

设置你现在使用的系统,因为调用系统命令不同
 

Gnuplot(const std::string &style = "points");

初始化构造函数,参数可以缺省

Gnuplot(const std::vector<double> &x,
                const std::string &title = "",
                const std::string &style = "points",
                const std::string &labelx = "x",
                const std::string &labely = "y");

初始化构造函数,输入参数:函数值,标题,线型,坐标轴名

Gnuplot(const std::vector<double> &x,
                const std::vector<double> &y,
                const std::string &title = "",
                const std::string &style = "points",
                const std::string &labelx = "x",
                const std::string &labely = "y");

初始化构造函数,输入参数:x坐标值,y坐标值,标题,线型,坐标轴名

Gnuplot(const std::vector<double> &x,
                const std::vector<double> &y,
                const std::vector<double> &z,
                const std::string &title = "",
                const std::string &style = "points",
                const std::string &labelx = "x",
                const std::string &labely = "y",
                const std::string &labelz = "z");

初始化构造函数,输入参数:x坐标值,y坐标值,z坐标值,标题,线型,坐标轴名

Gnuplot& cmd(const std::string &cmdstr);

给gnuplot输入命令
 

Gnuplot& showonscreen();

将数据在窗口中作图

<pre name="code" class="cpp">Gnuplot& savetops(const std::string &filename = "gnuplot_output");
 

讲数据保存到文件中

 Gnuplot& set_style(const std::string &stylestr = "points");

设置画图的线型:lines, points, linespoints, impulses, dots, steps, fsteps, histeps, boxes, histograms, filledcurves

Gnuplot& set_smooth(const std::string &stylestr = "csplines");

设置光滑属性:csplines, bezier, acsplines (for data values > 0), sbezier, unique, frequency。设置后设置线型不起作用

inline Gnuplot& unset_smooth(){ smooth = ""; return *this;}; 

取消光滑属性,初始默认没有光滑属性
 

Gnuplot& set_pointsize(const double pointsize = 1.0);

设置画图点的大小
 

inline Gnuplot& set_grid()	{cmd("set grid");return *this;};

打开网格

inline Gnuplot& unset_grid(){cmd("unset grid");return *this;};

关闭网格,初始默认关闭网格

inline Gnuplot& set_multiplot(){cmd("set multiplot") ;return *this;};

使得一个窗口画多个图形

inline Gnuplot& unset_multiplot(){cmd("unset multiplot");return *this;};

关闭画多个图形这宗模式

Gnuplot& set_samples(const int samples = 100);

设置画图插值点数

Gnuplot& set_isosamples(const int isolines = 10);

设置等值线密度,适用于3d-plot
 

Gnuplot& set_hidden3d(){cmd("set hidden3d");return *this;};

隐藏3d图形中的线

inline Gnuplot& unset_hidden3d(){cmd("unset hidden3d"); return *this;}; 

取消隐藏隐藏3d图形中的线,默认是不隐藏的

Gnuplot& set_contour(const std::string &position = "base");

画出3d图形的轮廓

inline Gnuplot& unset_contour(){cmd("unset contour");return *this;};

隐藏3d图形的轮廓

inline Gnuplot& set_surface(){cmd("set surface");return *this;};

画出3d图形的表面

inline Gnuplot& unset_surface(){cmd("unset surface"); return *this;}

关闭3d图形的表面,默认是打开的

Gnuplot& set_legend(const std::string &position = "default"); 

打开图例

inline Gnuplot& unset_legend(){cmd("unset key"); return *this;}

关闭图例

inline Gnuplot& set_title(const std::string &title = "")

设置标题

inline Gnuplot& unset_title(){this->set_title();return *this;}

关闭标题

Gnuplot& set_ylabel(const std::string &label = "x");

设置x坐标轴名字

Gnuplot& set_xlabel(const std::string &label = "y");

设置y坐标轴名字

Gnuplot& set_zlabel(const std::string &label = "z");

设置z坐标轴名字

Gnuplot& set_xrange(const double iFrom,
                        const double iTo);

设置x轴显示的范围

Gnuplot& set_yrange(const double iFrom,
                        const double iTo);

设置y轴显示的范围

Gnuplot& set_zrange(const double iFrom,
                        const double iTo);

设置z轴显示的范围

inline Gnuplot& set_xautoscale(){cmd("set xrange restore");cmd("set autoscale x");return *this;};

设置x轴为默认设置

inline Gnuplot& set_yautoscale(){cmd("set yrange restore");cmd("set autoscale y");return *this;};

设置y轴为默认设置

inline Gnuplot& set_zautoscale(){cmd("set zrange restore");cmd("set autoscale z");return *this;};

设置z轴为默认设置

Gnuplot& set_xlogscale(const double base = 10);
Gnuplot& set_ylogscale(const double base = 10);
Gnuplot& set_zlogscale(const double base = 10);
inline Gnuplot& unset_xlogscale(){cmd("unset logscale x"); return *this;};
inline Gnuplot& unset_ylogscale(){cmd("unset logscale y"); return *this;};
inline Gnuplot& unset_zlogscale(){cmd("unset logscale z"); return *this;};

设置/取消设置轴为对数坐标

    /// plot a single std::vector: x
    ///   from file
    Gnuplot& plotfile_x(const std::string &filename,
                        const unsigned int column = 1,
                        const std::string &title = "");
    ///   from std::vector
    template<typename X>
    Gnuplot& plot_x(const X& x, const std::string &title = "");




    /// plot x,y pairs: x y
    ///   from file
    Gnuplot& plotfile_xy(const std::string &filename,
                         const unsigned int column_x = 1,
                         const unsigned int column_y = 2,
                         const std::string &title = "");
    ///   from data
    template<typename X, typename Y>
    Gnuplot& plot_xy(const X& x, const Y& y, const std::string &title = "");




    /// plot x,y pairs with dy errorbars: x y dy
    ///   from file
    Gnuplot& plotfile_xy_err(const std::string &filename,
                             const unsigned int column_x  = 1,
                             const unsigned int column_y  = 2,
                             const unsigned int column_dy = 3,
                             const std::string &title = "");
    ///   from data
    template<typename X, typename Y, typename E>
    Gnuplot& plot_xy_err(const X &x, const Y &y, const E &dy,
                         const std::string &title = "");




    /// plot x,y,z triples: x y z
    ///   from file
    Gnuplot& plotfile_xyz(const std::string &filename,
                          const unsigned int column_x = 1,
                          const unsigned int column_y = 2,
                          const unsigned int column_z = 3,
                          const std::string &title = "");
    ///   from std::vector
    template<typename X, typename Y, typename Z>
    Gnuplot& plot_xyz(const X &x,
                      const Y &y,
                      const Z &z,
                      const std::string &title = "");

从文件中读取数据画图

    /// plot an equation supplied as a std::string y=f(x), write only the function f(x) not y=
    /// the independent variable has to be x
    /// binary operators: ** exponentiation, * multiply, / divide, + add, - substract, % modulo
    /// unary operators: - minus, ! factorial
    /// elementary functions: rand(x), abs(x), sgn(x), ceil(x), floor(x), int(x), imag(x), real(x), arg(x),
    ///   sqrt(x), exp(x), log(x), log10(x), sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), atan2(y,x),
    ///   sinh(x), cosh(x), tanh(x), asinh(x), acosh(x), atanh(x)
    /// special functions: erf(x), erfc(x), inverf(x), gamma(x), igamma(a,x), lgamma(x), ibeta(p,q,x),
    ///   besj0(x), besj1(x), besy0(x), besy1(x), lambertw(x)
    /// statistical fuctions: norm(x), invnorm(x)
    Gnuplot& plot_equation(const std::string &equation,
                           const std::string &title = "");

    /// plot an equation supplied as a std::string z=f(x,y), write only the function f(x,y) not z=
    /// the independent variables have to be x and y
    Gnuplot& plot_equation3d(const std::string &equation,
                             const std::string &title = "");

画函数图像

    Gnuplot& plot_image(const unsigned char *ucPicBuf,
                        const unsigned int iWidth,
                        const unsigned int iHeight,
                        const std::string &title = "");

画图片

inline Gnuplot& replot(void){if (nplots > 0) cmd("replot");return *this;};

重画刚才的图
 

Gnuplot& reset_plot();

将画板清空

Gnuplot& reset_all();

将所有变量清空
 

void remove_tmpfiles();

删除暂存的文件

inline bool is_valid(){return(valid);};

检测会话是否有效
 


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值