本文介绍了打印sprintf的错误,而输入是在热图gnuplot的符号组成的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作热图上具有独特的数据集。该数据集包括一个象征。
这里是我的数据集1q.txt的例子

I am working on heat map with a unique dataset. The dataset consists of a symbol.Here is the example of my dataset 1q.txt

            one         two         three
2009        0/0    1    0/0    1    0/0      1
2010        0/0    1    0/0    1    0/0      1
2011        0/0    1    0/0    1    6/179.5  1
2012        0/0    1    2/0.4  1    11/83.0  1
2013        7/0.8  1    7/21.3 1    17/268.5 1
2014        1/3.5  1    4/7.7  1    9/37.9   1

和这里是我的gnuplot脚本

and here is my gnuplot script

set term pos eps font 20
unset colorbox
unset key
set nocbtics
set cblabel "Score"
set cbtics scale 0
set cbrange [ 0.00000 : 110.00000 ] noreverse nowriteback
set palette defined ( 0.0 "#FFFFFF",\
                      1 "#FFCCCC",\
                      2 "#FF9999 ",\
                      3 "#FF6666")

set size 1, 0.5
set output '1q.eps'
YTICS="`awk 'BEGIN{getline}{printf "%s ",$1}' '1q.dat'`"
XTICS="`head -1 '1q.dat'`"
set for [i=1:words(XTICS)] xtics ( word(XTICS,i) i-1 )
set for [i=1:words(YTICS)] ytics ( word(YTICS,i) i-1 )

set for [i=1:words(XTICS)] xtics ( word(XTICS,i) 2*i-1 )
plot "<awk '{$1=\"\"}1' '1q.dat' | sed '1 d'" matrix every 2::1 w image, \
     '' matrix using ($1+1):2:(sprintf('%.f', $3)) every 2 with labels

我想在这里做的是我要显示0/0作为一个热图标签和整数作为热图的颜色。

What I'm trying to do here is I want to displaying "0/0" as a label in the heatmap and the integer number as a heatmap color.

这是我在这里所面临的问题是gnuplot的前只取了一些/
 并忽略其他之一。

The problem that I face here is the gnuplot only take a number before "/" and ignore the other one.

下面是我当前的阴谋的结果。

Here is the result of my current plot.

如何使热图显示像1 / 3.5一拉布勒,并有颜色的基础上的整数。

How to make the heatmap show a lable like "1/3.5" and have color based on the integer number.

推荐答案

有没有必要使用的sprintf 可言。只需使用 stringcolumn 作为保存在数据文件中得到一个列的原始内容:

There is no need to usesprintf at all. Simply use stringcolumn to get the raw content of a column as saved in the data file:

plot "<awk '{$1=\"\"}1' '1q.dat' | sed '1 d'" matrix every 2::1 w image, \
 '' matrix using ($1+1):2:(stringcolumn(3)) every 2 with labels

这篇关于打印sprintf的错误,而输入是在热图gnuplot的符号组成的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 04:59