博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PGPLOT Examples using fortran and c language.
阅读量:5827 次
发布时间:2019-06-18

本文共 2324 字,大约阅读时间需要 7 分钟。

PGPLOT Examples

PGPLOT is designed to make it easy to generate simple graphs, while providing full capability for more complex graphs. As an example of a simple graph, here is a graph of the function y = x� exp(-x), which was drawn with six PGPLOT subroutine calls.
[graphics] This figure is a . With no change to the source code, the program can also generate files in other formats, such as . Here is the Fortran code required to draw this graph, with comments to explain the purpose of each subroutine call. The question mark as an argument to
PGOPENallows the user to specify a file name and file format at run time.
PROGRAM EX1      INTEGER PGOPEN, I      REAL XS(9), YS(9), XR(101), YR(101)C Compute numbers to be plotted.      DO 10 I=1,101          XR(I) = 0.1*(I-1)          YR(I) = XR(I)**2*EXP(-XR(I)) 10   CONTINUE      DO 20 I=1,9          XS(I) = I          YS(I) = XS(I)**2*EXP(-XS(I)) 20   CONTINUEC Open graphics device.      IF (PGOPEN('?') .LT. 1) STOPC Define coordinate range of graph (0 < x < 10, 0 < y < 0.65),C and draw axes.      CALL PGENV(0., 10., 0., 0.65,  0,  0)C Label the axes (note use of \u and \d for raising exponent).      CALL PGLAB('x', 'y', 'PGPLOT Graph: y = x\u2\dexp(-x)')C Plot the line graph.      CALL PGLINE(101, XR, YR)C Plot symbols at selected points.      CALL PGPT(9, XS, YS, 18)C Close the graphics device.      CALL PGCLOS      END
The same program can be written in C, using the cpgplot library.
#include "cpgplot.h"#include "math.h"int main(){   int i;   float xs[9], ys[9];   float xr[101], yr[101];   /* Compute numbers to be plotted. */   for (i=0; i<101; i++) {     xr[i] = 0.1*i;     yr[i] = xr[i]*xr[i]*exp(-xr[i]);   }   for (i=0; i<9; i++) {     xs[i] = i+1;     ys[i] = xs[i]*xs[i]*exp(-xs[i]);   }   /* Open graphics device. */   if (cpgopen("?") < 1)     return 1;   /* Define coordinate range of graph (0 < x < 10, 0 < y < 0.65),      and draw axes. */   cpgenv(0., 10., 0., 0.65, 0, 0);   /* Label the axes (note use of \\u and \\d for raising exponent). */   cpglab("x", "y", "PGPLOT Graph: y = x\\u2\\dexp(-x)");   /*  Plot the line graph. */   cpgline(101, xr, yr);   /* Plot symbols at selected points. */   cpgpt(9, xs, ys, 18);   /* Close the graphics device */   cpgclos();   return 0;}

转载于:https://www.cnblogs.com/shaoguangleo/archive/2011/11/21/2806063.html

你可能感兴趣的文章
关于Android四大组件的学习总结
查看>>
java只能的round,ceil,floor方法的使用
查看>>
由于无法创建应用程序域,因此未能执行请求。错误: 0x80070002 系统找不到指定的文件...
查看>>
新开的博客,为自己祝贺一下
查看>>
【CQOI2011】放棋子
查看>>
采用JXL包进行EXCEL数据写入操作
查看>>
一周总结
查看>>
将txt文件转化为json进行操作
查看>>
线性表4 - 数据结构和算法09
查看>>
Online Patching--EBS R12.2最大的改进
查看>>
Binary Search Tree Iterator leetcode
查看>>
uva-317-找规律
查看>>
Event事件的兼容性(转)
查看>>
我的2014-相对奢侈的生活
查看>>
zoj 2412 dfs 求连通分量的个数
查看>>
Java设计模式
查看>>
一文读懂 AOP | 你想要的最全面 AOP 方法探讨
查看>>
Spring Cloud 微服务分布式链路跟踪 Sleuth 与 Zipkin
查看>>
ORM数据库框架 SQLite 常用数据库框架比较 MD
查看>>
华为OJ 名字美丽度
查看>>