简体   繁体   English

在R和gnuplot中为3D图绘制大量的x,y,z点,并在每个时间步提取bmp / gif / png文件

[英]Plotting large number of x, y, z points for 3D plot in R and gnuplot and extracting bmp/gif/png files at each timestep

I have large set of x, y, z points (8000 points) where x, and y are fixed and z-coordinates change at each time step (around 100 time steps).Each time step has a separate data file(x,y,z) for each time step. 我有大量的x,y,z点(8000个点),其中x和y是固定的,并且z坐标在每个时间步长(大约100个时间步长)都变化。每个时间步长都有一个单独的数据文件(x,y ,z)每个时间步。 What would be best way to plot these data points for each file to show the change of z-coordinates in time? 绘制每个文件的这些数据点以显示z坐标随时间变化的最佳方法是什么? May be produce 3D surface/scatter plot at each time step and use those gif/bmp files to make a video file. 可以在每个时间步骤生成3D表面/散点图,并使用这些gif / bmp文件制作视频文件。 I can use plotting software to plot x, y, z at each time step but that would be tedious to do it 100 times manually. 我可以使用绘图软件在每个时间步绘制x,y,z,但是手动进行100次比较麻烦。 Can you please suggest me a way to do it in R and gnuplot? 您能建议我在R和gnuplot中做到这一点吗? I want to create picture files like the one linked here. 我想创建图片文件,就像这里链接的文件一样。 http://dl.dropbox.com/u/9267983/stack/1.gif http://dl.dropbox.com/u/9267983/stack/1.gif

Thank you 谢谢

For example my data sets at a particular time = 1.0 min 例如,我在特定时间的数据集= 1.0分钟

         4.00      4.00    126.6310
         8.00      4.00    126.3585
        12.00      4.00    126.1797
        16.00      4.00    126.0514
        20.00      4.00    125.8081
        24.00      4.00    125.3174
        28.00      4.00    124.6824
        32.00      4.00    124.0422
        36.00      4.00    123.4376
        40.00      4.00    122.8637
        44.00      4.00    122.4779
        48.00      4.00    122.4673
        52.00      4.00    122.4825
        56.00      4.00    122.2762
        60.00      4.00    122.5483
        64.00      4.00    122.0322
        68.00      4.00    122.5442
        72.00      4.00    122.2031
        76.00      4.00    122.4452
        80.00      4.00    122.3936
        84.00      4.00    122.4258
        88.00      4.00    122.4239
        92.00      4.00    122.4239
        96.00      4.00    122.4226

In R, the 3D option that is best for parametric plotting is the rgl package. 在R中, rgl软件包是最适合参数绘图的3D选项。

require(rgl)
x=sin( (1:100)/10 )
 y=cos( (1:100)/10 )
 z=(1:100)/100
 lines3d(x,y,z)
 #after rotation with cursor controls
 rgl.postscript("spiral.ps""
 # and conversion to a png file

在此处输入图片说明

Give us 50-100 of your points and we can demonstrate with real data! 给我们您的50-100点,我们可以用真实的数据进行演示!

Based on your sample data, I generated a set of fake data and generated a series of plots and saved them as an individual images (sequentially named). 根据您的样本数据,我生成了一组假数据并生成了一系列图并将其保存为单独的图像(顺序命名)。 Such images can be converted to animated gif or movie files using ImageMagick, QuickTime Pro, GIMP, or any other capable graphics editor. 可以使用ImageMagick,QuickTime Pro,GIMP或任何其他支持的图形编辑器将此类图像转换为动画gif或电影文件。

在此处输入图片说明

Below is my gnuplot code. 以下是我的gnuplot代码。 Note that do-loops are newly introduced in gnuplot version 4.6 and will not work in earlier versions. 请注意,在gnuplot 4.6版中新引入了do循环,并且在早期版本中不起作用。 With an older version of gnuplot, you can use an external shell script to run the same script multiple times while changing the output file name and the data file name to produce the same result. 对于旧版本的gnuplot,您可以使用外部Shell脚本多次运行同一脚本,同时更改输出文件名和数据文件名以产生相同的结果。

set term pngcairo
set palette defined ( 0    '#000fff',\
                      0.99 '#000fff',\
                      1    '#90ff70',\
                      1.99 '#90ff70',\
                      2    '#ee0000',\
                      2.99 '#ee0000')
set ticslevel 0
set view 51,120

do for [t=0:29] {
  set output sprintf("%d.png", t)
  splot sprintf("< awk '{if ($2!=prev) print ; prev=$2; print $0}' %d.dat", t) w p pt 7 linecolor palette notitle
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM