Anhbayar Otgonbayar
Anhbayar Otgonbayar

Reputation: 43

Heat map of 4x1000 data in gnuplot

I have 1000 x 4 data having float values between [0, 100]. How can I create comparison heat map for this data in gnuplot?

I have tried the demo version of heatmap example on Gnuplot. However, I could not find my answer from it.

The data looks like this:

enter image description here

And what I want to show comparison of each columns(sorted) in heatmap.

For example:

enter image description here

Upvotes: 0

Views: 175

Answers (1)

Ethan
Ethan

Reputation: 15143

As I understand it you want to treat the columns individually rather than treating the whole thing as a matrix. The following gnuplot commands will do that:

unset xtics
unset ytics
unset border
set bmargin screen 0.1
set key samplen -1
set style fill solid
set palette defined (0 "forest-green", 1 "goldenrod")

plot for [col=1:4] 'data' \
     using (col):0:(0.45):(1.0):col with boxxy \
     lc palette title columnhead(col) at first col, graph -0.05

Notes:

  • The boxxy style expects column input x:y:delta_x:delta_y [:optional color]
  • We give it the column number for x, the line number for y, and a constant size width and height. You can adjust the width to reduce the gap between columns.
  • The bottom margin is increased to leave room for the labels
  • The titles are placed individually under the plot rather than in a key box

You mention sorting but it is not clear exactly what you want. If the idea is to sort the values within each column prior to plotting, I think that will have to be done by invoking a system command. On linux this could be done by replacing the first line of the plot command with something like:

plot for [col=1:4] sprintf("<sort -n -k %d data",col) \
    etc 

enter image description here

Upvotes: 2

Related Questions