Plplot绘制随时间变换的动态图
来源:互联网 发布:sql中的exists 编辑:程序博客网 时间:2024/06/08 19:27
这是一张随时间变换的动态图像,用到的plot函数有:
// Create 1d stripchart,可同时绘4条函数
void stripc( PLINT *id, const char *xspec, const char *yspec,
PLFLT xmin, PLFLT xmax, PLFLT xjump, PLFLT ymin, PLFLT ymax,
PLFLT xlpos, PLFLT ylpos,
bool y_ascl, bool acc,
PLINT colbox, PLINT collab,
const PLINT colline[], const PLINT styline[], const char *legline[],
const char *labx, const char *laby, const char *labtop );
// Add a point to a stripchart.
void stripa( PLINT id, PLINT pen, PLFLT x, PLFLT y );
// Deletes and releases memory used by a stripchart.
void stripd( PLINT id );
程序代码如下:
#include "plc++demos.h"#ifdef PL_HAVE_UNISTD_H# include <unistd.h>#else# ifdef PL_HAVE_POLL# include <poll.h># endif#endif#ifdef PL_USE_NAMESPACEusing namespace std;#endifplstream *pls;static PLINT pl_errcode= 0;static char errmsg[160]= "";int main( int argc, const char ** argv ){PLINT id_StripChart, nsteps = 1000;bool autoy, acc;PLFLT y1, y2, y3, y4, init_ymin, init_ymax, xlab, ylab;PLFLT t, init_tmin, init_tmax, tjump, dt, noise;PLINT colbox, collab, colline[4]={0}, styline[4]={0};const char *legline[4] ;// plplot initializationpls = new plstream();// Parse and process command line arguments.pls->parseopts( &argc, argv, PL_PARSE_FULL );// Specify some reasonable defaults for ymin and ymax// The plot will grow automatically if needed (but not shrink)init_ymin = -0.1;init_ymax = 0.1;// Specify initial tmin and tmax -- this determines length of window.// Also specify maximum jump in t// This can accomodate adaptive timestepsinit_tmin = 0.;init_tmax = 10.;tjump = 0.3; // percentage of plot to jump// Axes options same as plbox.// Only automatic tick generation and label placement allowed// Eventually I'll make this fanciercolbox = 1;collab = 3;styline[0] = colline[0] = 2; // pens color and line stylestyline[1] = colline[1] = 2;styline[2] = colline[2] = 2;styline[3] = colline[3] = 2;legline[0] = "sin"; // pens legendlegline[1] = "";legline[2] = "";legline[3] = "";xlab = 0.; ylab = 0.25; // legend positionautoy = true; // autoscale yacc = true; // don't scrip, accumulate// Initialize PLplot.pls->sdev("qtwidget");pls->init();pls->adv( 0 );pls->vsta();// Register our error variables with PLplot// From here on, we're handling all errors herepls->sError( &pl_errcode, errmsg );pls->stripc( &id_StripChart, "bcnst", "bcnstv",init_tmin, init_tmax, tjump, init_ymin, init_ymax,xlab, ylab,autoy, acc,colbox, collab,colline, styline, legline,"t", "", "Strip chart demo" );if ( pl_errcode ){cout << errmsg << endl;delete pls;exit( 1 );}// Let plplot handle errors from here onpls->sError( NULL, NULL );autoy = false; // autoscale yacc = true; // accumulate/// This is to represent a loop over time// Let's try a random walk processy1 = y2 = y3 = y4 = 0.0;dt = 0.1;for ( PLINT n = 0; n < nsteps; n++ ){t = (double) n * dt;y1 = sin( t * M_PI / 18. );// There is no need for all pens to have the same number of// points or beeing equally time spaced.pls->stripa( id_StripChart, 0, t, y1 );}// Destroy strip chart and it's memorypls->stripd( id_StripChart );delete pls;return 0;}vs2010工程地址:plplot_time
参考文献:http://plplot.sourceforge.net/examples.php?demo=17&lbind=C%2B%2B
0 0
- Plplot绘制随时间变换的动态图
- plplot绘制3d图
- Plplot绘制简单2D函数图
- Plplot绘制简单2D函数图二
- [Geiv]第一章:静态绘制(二) 图元的位置变换
- 如何捕捉推荐系统中随时间变化的动态信息
- 动态加载一组小图并可随时显示它们的详细大图
- Android绘制时的坐标系变换
- VB 控件数组的动态建立 随时添加控件
- 实现图标的动态变换:
- jschart 绘制动态图
- Echarts实现折线图随时刻动态加载
- 随时间变化的图形(javascript)
- 随时间变化的数据,官方实例
- 15.7 随时间变化的实例
- 动态绘制图形的基本思路
- Android 绘制动态的曲线图
- FusionChart动态报表的绘制
- Linux--linux tail 命令详解
- 安装python-mysql出现的问题以及解决方法
- shell 编程
- 平面设计大神养成记之PS篇——编辑菜单栏
- M--二分查找
- Plplot绘制随时间变换的动态图
- OAuth2.0忽略state参数引发的CSRF漏洞
- day_06
- 事物详解
- 【微信小程序】icon系统图标案例
- 排序
- 一个Matplotlib绘图例子
- bisheng脚手架源码分析和插件机制
- 《金字塔原理》