Bogdan
Bogdan

Reputation: 13

Offset gnuplot grid lines so that they match xtics

How do I move the vertical grid lines so that they match the horizontal labels/xtics?

In the following image, the vertical grid lines don't line up with the xtics:

enter image description here

I tried setting the xtics offset before setting the grid, but that doesn't seem to work.Here's my current script:

    #!/usr/bin/gnuplot -persist
    set terminal png nocrop font small size 40000,800
    set output 'decode3.png'
    set style data linespoints
    set title "Raw Audio Chunk"
    set xlabel "Count"
    set ylabel "Sample Value"
    set xtics 16 offset 10
    set ytics 10000
    set grid
    plot "decode3_Samsung_Exhibit.csv" 

Upvotes: 1

Views: 998

Answers (1)

Christoph
Christoph

Reputation: 48440

Thats the wrong way of thinking about this! The offset parameter only shifts the xtics labels (in your case by 10 character widths), but the xtics remain at their original positions. And the grid lines are drawn at the tic positions.

What you probably want is to shift the data a bit to the right. That is done by shifting the actual x-values to the right like

set xtics 16
set grid
plot "decode3_Samsung_Exhibit.csv" using ($1 + 10):2

That assumes, that your data file has two columns. The x-values are shifted by 10 (in units of the x-axis) to the right.

Upvotes: 1

Related Questions