I have a Gaussian curve drawn via gnuplot and I want to have a line which goes up from the x-axis, stops exactly where it hits the curve, and goes perpendicular to the left to hit the y-axis, ideally displaying the values at both axis, and displaying a symbol where it intersects with the x-axis.
What is the right way to add this in gnuplot? I tried to play around with arrows using nohead but I am a newbie to gnuplot and can't seem to find a way to achieve what I need.
to draw a vertical line The range of t is controlled by the command set trange . In this case the vertical line is draw at x=3.
Offsets provide a mechanism to put a boundary around the data inside of an autoscaled graph.
I managed to find a simple solution to my needs. The arrow
can actually be used with nohead
by specifying the y
coordinates of the to
to be the function of the plot itself.
So lets say we have a function f(x), and we want to draw a line from x=3 to f(3) and the corresponding horizontal line y= f(3), all we have to do is add 2 arrows:
set arrow from 3,0 to 3,f(3) nohead
set arrow from 0,f(3) to 3,f(3) nohead
Since I also wanted tics to be added where the line intersects with the axis, if they're missing, one could then do:
set xtics add (3 3)
set ytics (f(3) f(3))
Since there might be decimal places involved on the y
axis one might also need to do something like this (in this case it has 3 decimal places):
set format y "%1.3f"
I didn't manage to find a way to do a label underneath a tic on the x-axis, but the above sufficed for my needs. Hope it helps for someone else looking for the same solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With