如何在gnuplot中获取中头箭头? [英] How to get a middle-headed arrow in gnuplot?

查看:53
本文介绍了如何在gnuplot中获取中头箭头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在gnuplot中绘制一个箭头,箭头的头部出现在箭头的中间,而不是出现在两个极端之间.尝试过中头选项,但似乎不起作用.

I want to draw an arrow in gnuplot with the arrow head appearing in the middle of the arrow instead of either extremes. Tried middlehead option but doesn't seem to work.

这是我用来创建下面图像的脚本,

Here is the script that I am using to create the image below,

set style arrow 1 front head filled size screen 0.008,6 lt 1 lw 1
set arrow from  0.4750,-0.3592 to 1.05767,0.4179 as 1

推荐答案

正如安德拉斯(Andyras)所指出的:没有选择可以得到这个.但是,您可以创建一个为您构建两个箭头并进行中间点计算的函数.函数middlearrow会构建一个包含两个箭头定义的字符串,然后必须使用eval对其进行处理:

As andyras already pointed out: there is no option to get this. However, you can create a function which builds the two arrows for you and does the calculation of the intermediate point. The function middlearrow builds together a string containing both arrow definitions, which must then be processed with eval:

set style arrow 1 front head filled size screen 0.03,15 lt 1 lw 1
middlearrow(from_x, from_y, to_x, to_y) = \
        sprintf('set arrow from %f,%f to %f,%f as 1 nohead;', 0.5*(from_x + to_x), 0.5*(from_y + to_y), to_x, to_y).\
        sprintf('set arrow from %f,%f to %f,%f as 1', from_x, from_y, 0.5*(from_x + to_x), 0.5*(from_y + to_y)) 

eval(middlearrow(0.1,0.1,0.9,0.9))

set xrange [0:1]
set yrange [0:1]

plot 0

4.6.4的结果:

这篇关于如何在gnuplot中获取中头箭头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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