How to get the middle arrow in gnuplot?

I want to draw an arrow in gnuplot when the arrow appears in the middle of the arrow and not at the extreme. I tried the midline option, but it doesn't seem to work.

Here is the script that I use 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

enter image description here

+2
source share
2 answers

As andyras has already pointed out: there is no way to get this. However, you can create a function that creates two arrows for you and calculates an intermediate point. The function middlearrowconcatenates a string containing both arrow definitions, which must then be processed using 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

Result from 4.6.4:

enter image description here

+5
source

Draw two arrows, one with and without a head.

----> + ----- = ---->-----
0
source

Source: https://habr.com/ru/post/1612465/


All Articles