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


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

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

From Ethan A Merritt <EAMerritt@gmail.com>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: Plot emtpy labels from file entries using 'matrix with image'
Date 2014-11-20 21:39 -0800
Organization made entirely of Lego
Message-ID <m4mj5d$o71$1@dont-email.me> (permalink)
References <m4l428$pv1$1@virtdiesel.mng.cu.mi.it>

Show all headers | View raw


Let's try the simple answer first.  You used the command 

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

but you probably did not realize that a curious property of NaN is that
is by definition never equal to any other entity, including itself.
So   A=NaN;   if (A != A) print "A is not a number"

So your test would better be written

  using 1:2:(($3!=$3) ? "" : sprintf('%.2f', $3))

Of course there may be other problems as well, but try that first.

By the way, it is very rare to have to use multiplot to create a
single plot.  I don't think you really need to do so here either.
But leave that for now.
	
	Ethan



neurino wrote:

> 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 | NextPrevious in thread | Next 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