1

I'm trying to create a heatmap with gnuplot. In input I have a matrix with N rows and M columns but the axis should be always label with numbers going from 0 to 1. I'm not exactly sure about the best way to count the lines and rows of my input matrix.

To show you some code:

set term png
set out "test.png"
set pm3d map
set size ratio 1
set pm3d interpolate 0,0
set tics out nomirror
splot 'test.dat' matrix using ($1/N):($2/M):3 notitle
set out

How can I calculate M and N in this script?

1 Answer 1

2

you could use:

stats 'test.dat' nooutput
N = STATS_records
M = STATS_columns

before invoking splot

Sign up to request clarification or add additional context in comments.

2 Comments

Your solution works! What is weird is that now my chart doesn't cover all the allowed space of the chart, as it did before, but leaves a few pixels uncovered in the top and right sides, where I see the grid behind. Any idea why?
Solved this problem by using N-1 and M-1. Thank you anyway!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.