Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnuplot horizontal space before first line point and after last

Tags:

gnuplot

using: gnuplot 4.2 patchlevel 6

I am plotting candlesticks. The first and last data points are, of course, on the left and right Y axis bars. The first and last candlesticks are all but hidden by the axis bars. a la:

set terminal gif
set xtics rotate
plot    "test.csv" u 0:3:xtic(1) t "Avg" with lines, \
        "test.csv" u 0:4:5:6:7 t "MinMax&Stdv" with candlesticks

enter image description here

Is there a way to "fake" a null starting and ending point? I have tried adding zero values but that just grounds the plotted line(s) at the start and end.

like image 951
7 Reeds Avatar asked May 07 '26 05:05

7 Reeds


1 Answers

That's what set offsets is for: Add some offsets to gnuplots autoscaled range:

Without offsets (this is your case):

$data <<EOD
1 1
2 2
EOD
plot $data with lp pt 7 ps 2 notitle

enter image description here

With offsets in x-direction:

$data <<EOD
1 1
2 2
EOD
set offsets 0.1, 0.1, 0, 0
plot $data with lp pt 7 ps 2 notitle

enter image description here

As you can see, you get offsets at the left and right plot margins. However, the margin's size isn't 0.1 in units of the first axis, but the value is rounded to the next auto-generated tic.

To work around this, you can add set autoscale xfix:

$data <<EOD
1 1
2 2
EOD
set offsets 0.1, 0.1, 0, 0
set autoscale xfix
plot $data with lp pt 7 ps 2 notitle

enter image description here

like image 164
Christoph Avatar answered May 09 '26 07:05

Christoph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!