A large collection of Gnuplot examples

I needed to use Gnuplot a little bit over the last few days, mostly to create 2D line charts, and these are my brief notes on how to get started with Gnuplot. If you haven’t used it before, it’s an amazing tool for creating graphs and charts. Jumping right in … Installing gnuplot To get started, you can use MacPorts or Homebrew to install Gnuplot on macOS systems: port install gnuplot brew install gnuplot Note that with Mac OS X Yosemite (10.10.x) running on an old Mac, I had to use this brew command instead: ...

January 9, 2025 · Unknown

Pretty Plots with Gnuplot

Given a data file that looks something like this: // f(GHz) S211(dB) S212(dB) S213(dB) S214(dB) S215(dB) S216(dB) S217(dB) 0.100E+00 -0.743E-03 0.586E-03 -0.390E-02 -0.787E-02 -0.930E-02 -0.159E-01 -0.164E-01 0.200E+00 -0.354E-02 -0.616E-02 -0.161E-01 -0.270E-01 -0.374E-01 -0.537E-01 -0.673E-01 0.300E+00 -0.820E-02 -0.174E-01 -0.364E-01 -0.589E-01 -0.843E-01 -0.117E+00 -0.152E+00 0.400E+00 -0.147E-01 -0.331E-01 -0.649E-01 -0.104E+00 -0.150E+00 -0.206E+00 -0.272E+00 We want to make a plot. The X-axis of the plot is column 1 and the Y-axes are all the other columns. The software we’re going to use is gnuplot. ...

January 9, 2025 · Unknown

使用GMT在平面图上绘制轨迹动画

此脚本可用于在平面图上绘制轨迹。例子为绘制LGD算法的迭代路径,数据如下(仅截取前10行): 0 20 20 20 20 1 21.2864 20.6638 21 21 2 21.9939 21.0072 23.198 23.3067 3 22.4359 21.2145 26.3405 27.2079 4 22.5849 21.2829 32.1681 37.2527 5 26.0376 22.8571 32.8254 37.0327 6 28.1978 23.6712 33.8682 36.4159 7 31.0379 24.6084 34.8022 35.6868 8 31.104 24.626 37.3802 33.666 9 32.2038 24.918 38.7026 32.4291 数据共5列,分别为序号、轨迹1x、轨迹1y、轨迹2x、轨迹2y。 脚本 #!/usr/bin/env bash # 1. Create files needed in the loop cat << 'EOF' > pre.sh gmt begin pre gmt set FONT_ANNOT_PRIMARY=15p,Times-Roman,black gmt set FONT_LABEL=15p,Times-Roman,black gmt set MAP_GRID_CROSS_SIZE_PRIMARY=5p gmt set MAP_FRAME_PEN=thinnest,black gmt set MAP_TICK_LENGTH_PRIMARY=4p/2p gmt grd2cpt data/gauss_model.nc -Clapaz -R0/100/0/100 -Z -D gmt grdimage data/gauss_model.nc -R0/100/0/100 -Bxag+l"x (m)" -Byag+l"y (m)" -JX15c/15c -X4.5c -Y1.5c gmt end EOF # 2. Set up the main frame script cat << 'EOF' > main.sh gmt begin # Plot smooth blue curve and dark red dots at all steps so far gmt convert data/lgd_trace.txt -qi0:${MOVIE_FRAME} > data.txt gmt plot data.txt -W0.05p,white -R0/100/0/100 -JX15c/15c -X4.5c -Y1.5c -i1,2 gmt plot data.txt -Sc0.05i -Gred -i1,2 gmt plot data.txt -W0.05p,yellow -R0/100/0/100 -JX15c/15c -i3,4 gmt plot data.txt -Sc0.05i -Gblack -i3,4 gmt end EOF # 3. Run the movie gmt movie main.sh -Sbpre.sh -Cxga -Tdata/lgd_trace.txt -Vi -D5 -Zs -Nlgd_anim -Fmp4 动画 您的浏览器不支持视频标签 查看完整脚本。

December 26, 2024 · 张壹

一个简单的GMT动画例子

使用GMT程序包内的movie命令可以生成动画,更好地展示数据的动态变化。下面是一个利用该命令绘制动画的简单例子: 您的浏览器不支持视频标签 1. 准备程序 首先编写动画背景图的生成脚本,包括生成绘图所需的数据等工作也可以在此完成(如果已有外部数据则不需要)。在实际运行中不需要手动执行此脚本,而是通过movie命令调用。 # 使用heredoc方式将脚本保存到一个shell文件pre.sh # 在<<后添加-表示忽略tab制表符(注意不会忽略空格) cat <<- EOF > pre.sh # 使用gmt math生成数据,=号后接输出文件名称 # -T命令指定x坐标范围 # T SIND指定要计算的函数名称 gmt math -T0/360/10 T SIND = sin_point.txt gmt math -T0/360/1 T SIND = sin_curve.txt # 开始绘制底图 gmt begin # 使用gmt basemap绘制一张空的底图 具体的名称含义查看gmt文档 # -R指定坐标范围 -JX指定投影类型和地图大小 -X -Y平移图像 # -B指定坐标轴样式(包括ticks、labels和grids设置等) # --FONT_ANNOT_PRIMARY设置字体大小 gmt basemap -R0/360/-1.2/1.6 -JX22c/11.5c -X1c -Y1c \ -BWSne+glightskyblue -Bxa90g90f30+u@. -Bya0.5f0.1g1 --FONT_ANNOT_PRIMARY=9p gmt end # 结束 EOF 2. 准备主程序 编写动画生成的主脚本。movie命令内置了一批常量和变量可供使用,其中常量包括: ...

December 25, 2024 · 张壹

Visualising and plotting data with gnuplot

Introduction Data visualisation is extremely important for communicating the results of your research, either in a journal or to the general public, and for analysing and learning more about the characteristics of your data and system (so-called “exploratory data analysis”). One of the most fundamental tools in data visualisation is the two-dimensional plot (or graph). This tutorial will cover the basics of two-dimensional data visualisation using a program called gnuplot; a program which allows you to create high-quality, visually-pleasing figures and undertake robust post-hoc data analysis. ...

March 31, 2023 · Emily Kahl

PLY格式介绍

PLY 格式是在 1990 年代由 Greg Turk 和斯坦福图形实验室的其他人开发的,这也是它被称为斯坦福三角格式的原因。自那时起,该文件格式一直保持 1.0 版本,没有进一步的修改。 文件格式 一个简单的 PLY 对象由一组用于表示对象的元素组成。它包含一个顶点列表(由(x,y,z)三元组组成)和一个面列表(实际上是顶点列表的索引)。顶点和面是两种元素的例子,而大多数 PLY 文件主要由这两种元素构成。此外,还可以创建新的属性并将其附加到对象的元素上,这些但属性应以一种不会破坏旧程序的方式添加,以便旧程序在遇到这些新属性时仍能正常运行。读取应用程序也可以忽略这些属性。此外,还可以创建新的元素,并为这些元素定义属性。 PLY 文件格式的文件结构如下: 文件头 顶点列表 面列表 其他元素的列表 示例结构 在后续讨论中,我们将使用以下示例来说明 PLY 文件格式的各个部分。 ply format ascii 1.0 { ascii/binary,格式版本号 } comment made by Greg Turk { 以 comment 关键字开头的注释 } comment this file is a cube element vertex 8 { 定义“顶点”元素,文件中有 8 个 } property float x { 顶点包含浮点数“x”坐标 } property float y { y 坐标也是顶点的属性 } property float z { z 坐标也是 } element face 6 { 文件中有 6 个“面”元素 } property list uchar int vertex_index { “vertex_indices” 是一个整数列表 } end_header { 标记头部的结束 } 0 0 0 { 顶点列表的开始 } 0 0 1 0 1 1 0 1 0 1 0 0 1 0 1 1 1 1 1 1 0 4 0 1 2 3 { 面列表的开始 } 4 7 6 5 4 4 0 4 5 1 4 1 5 6 2 4 2 6 7 3 4 3 7 4 0 文件头 PLY 文件格式的文件头由 ASCII 文本组成,无论是 ASCII 格式还是二进制格式都是如此。头部部分的开始和结束由ply和end_header关键字标识。头部的开始有一个魔术词ply,用于让读取器识别 PLY 文件格式。下一行显示了该文件的版本号。PLY 文件格式中的注释以comment关键字开头。 ...

张壹