在图形gnuplot中绘制线和向量 [英] Plot lines and vector in graphical gnuplot

查看:74
本文介绍了在图形gnuplot中绘制线和向量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,任何人都不知道如何制作这种图形.

Hello everyone does anyone have any idea how to do this type of graph.

我试图绘制线和点的组合,但仍然失败.

I tried to plot the combination of lines and points but it still fails.

我想我已经画出一个范围来绘制下面的例子.

I think I have put a range to plot point to get the example I below.

dat.txt

0.936   1.735E-5
0.9317  1.682E-5
0.9274  1.633E-5
0.9232  1.588E-5
0.9189  1.545E-5
0.9146  1.504E-5
0.9103  1.466E-5
0.9061  1.431E-5
0.9018  1.396E-5
0.8975  1.364E-5
0.8932  1.333E-5
0.889   1.304E-5
0.8847  1.277E-5

用于情节

set xl 'Potential / V'
set yl 'Current / A'
plot 'dat.txt' u 1:2 w l lw 2 lt -1,\
'dat.txt' u 1:2 w p pt 2 ti ''

应如何绘制的示例

推荐答案

如果使用向量,则可能可以实现所需的目标.向量采用以下类型的参数:

If you use vectors you can probably achieve what you want. A vector takes the following type of argument:

plot 'mydata.dat' a:b:c:d with vectors

前两列 a b 是起点,后两列 c d 是相对的向量的坐标

The first two columns a and b are the starting point and last two c and d are relative coordinates of the vectors

因此,如果您可以从数据中计算出这些值,那么您应该能够达到预期的结果.

Hence if you can compute these values from your data, you should be able to achieve the desired result.

set xl 'Potential / V'
set yl 'Current / A'

定义可以使用的自定义箭头样式:

Define a custom arrow style that can be used:

set style arrow 1 head back filled linetype 1 linecolor rgb "red"  
set xrange [0.88:0.94]

然后定义函数以计算先前的x,y值和增量

Then define functions to compute the previous x, y values and the deltas

prev_x = NaN
prev_y = NaN
dx(x) = (x_delta = x-prev_x, prev_x = ($0 > 0 ? x : 1/0), x_delta)
dy(y) = (y_delta = y-prev_y, prev_y = ($0 > 0 ? y : 1/0), y_delta)

最后使用vectors命令绘制它们

Finally plot them using the vectors command

plot 'stats.dat' u 1:2 w l lw 2 lt -1, '' u (prev_x):(prev_y):(dx($1)):(dy($2)) every 2 w vectors arrowstyle 1 ti ''

OP在此处提供了完整的数据之后,该脚本已更改为以下:

After OP provided complete data here, the script was changed to the following:

set xl 'Potential / V'
set yl 'Current / A'

set style arrow 1 head back filled size screen 0.015,20,35 linetype 1 linecolor rgb "red"  

prev_x = NaN
prev_y = NaN

dx(x) = (xd = x-prev_x, prev_x = ($0 > 0 ? x : 1/0), xd)
dy(y) = (yd = y-prev_y, prev_y = ($0 > 0 ? y : 1/0), yd)

plot 'data.dat' u 1:2 w l lw 2 lt -1, '' u (prev_x):(prev_y):(dx($1)):(dy($2)) every 10 w vectors arrowstyle 1 ti ''

具有下图:

这篇关于在图形gnuplot中绘制线和向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆