Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #2638

Plot emtpy labels from file entries using 'matrix with image'

From neurino <lelli.luca@googlemail.com>
Newsgroups comp.graphics.apps.gnuplot
Subject Plot emtpy labels from file entries using 'matrix with image'
Date 2014-11-20 17:15 +0100
Organization C.U. srl News Server
Message-ID <m4l428$pv1$1@virtdiesel.mng.cu.mi.it> (permalink)

Show all headers | View raw


Hello group,

I have a file with a 4x4 score matrix and I'd like to plot the upper 
triangular with one color palette and the lower triangular with a 
different one, overlaying the score value (MWE code at the bottom).

The original file looks like this

0.00 0.65 0.65 0.25
0.25 0.00 0.75 0.25
0.50 0.60 0.00 0.25
0.75 0.25 0.10 0.00

First, I created two separate files and used multiplot to have 2 
different palettes.

FILE1 (upper triangular)
0.00 0.65 0.65 0.25
nan  0.00 0.75 0.25
nan nan 0.00 0.25
nan nan nan 0.00

FILE2 (lower triangular)
0.00 nan nan nan
0.25 0.00 nan nan
0.50 0.60 0.00 nan
0.75 0.25 0.10 0.00

Second, I plot the score values with
using 1:2:( sprintf('%.2f', $3 ) )

However, the 'nan' isn't interpreted as blank/empty and skipped but 
written onto the plot.

Any idea how to skip the nans and make gnuplot plot empty labels from 
individual entries of the data files?

The ternary operator in the following fashion do not seem to do the job
using 1:2:( \$3 == '' ? 1/0 : sprintf('%.2f', (\$3) ) )

Thanks.

---
set multiplot
set autoscale fix
unset key

set datafile missing "nan"
set cbrange [0:1]
unset colorbox

set palette defined (0 "white", 0.1 "#9ecae1", 1.0 "#3182bd")

plot FILE1 matrix with image, \
	FILE1 matrix using 1:2:( sprintf('%.2f', $3) ) with labels font ',16'

set palette defined (0 "white", 0.1 "#a1d99b", 1.0 "#31a354")

plot FILE2 matrix with image, \
	FILE2 matrix using 1:2:( sprintf('%.2f', $3) ) with labels font ',16'

unset multiplot

Back to comp.graphics.apps.gnuplot | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Plot emtpy labels from file entries using 'matrix with image' neurino <lelli.luca@googlemail.com> - 2014-11-20 17:15 +0100
  Re: Plot emtpy labels from file entries using 'matrix with image' Ethan A Merritt <EAMerritt@gmail.com> - 2014-11-20 21:39 -0800
    Re: Plot emtpy labels from file entries using 'matrix with image' neurino <lelli.luca@googlemail.com> - 2014-11-21 13:19 +0100
      Re: Plot emtpy labels from file entries using 'matrix with image' neurino <lelli.luca@googlemail.com> - 2014-11-22 15:26 +0100

csiph-web