Creating a heatmap with gnuplot, I want to have the tic labels read from the datafile on top and right of the heatmap, but setting axes x2y2
doesn't work as expected.
Example data file:
. sample1 sample2 sample3
gene1 10 0 17
gene2 11 2 21
gene3 9 27 0
Using
plot "data.csv" matrix rowheaders columnheaders with image
I get this plot, which is fine:
However, if I want to have the tic labels on the x2 and y2 axes, using i.e.
unset xtics
unset ytics
set x2tics
set y2tics
plot "data.csv" matrix rowheaders columnheaders using 1:2:3 axes x2y2 with image
gnuplot uses numbers instead of my labels:
Is there a way to attach the tic labels read from the file to the x2 and y2 axis?
You have to set x2label
and y2label
:
set x2label "Some label"
set y2label "Some other label"
plot sin(x) notitle axes x2y2
gives
If you also want to move the tic marks to the upper and right side, then you have to enable them for the x2
and y2
axes and disable them for x
and y
:
set x2label "Some label"
set y2label "Some other label"
unset xtics
unset ytics
set x2tics
set y2tics
plot sin(x) notitle axes x2y2
gives
Thanks for editing the question. It looks like your main question is whether you can use the labels read from the data file for the x2label
and y2label
. I am not sure if that is possible; it seems that the rowheaders
and columnheaders
options always refer to the first coordinate system.
As a workaround you can stick to xlabel
/ylabel
, and move them to the other side of the graph. This might require playing with the margins a little:
set tmargin 2
set lmargin 0.5
set rmargin at screen 0.75
set colorbox user origin screen 0.88, graph 0 size screen 0.05, graph 1
set xtics offset 0, graph 1.07
set ytics offset graph 1.15, 0
plot "data.csv" matrix rowheaders columnheaders with image
gives