具体定义直方图中条形的颜色

具体定义直方图中条形的颜色

请参阅下面更新的问题!:

(1 件旧物) 我有以下代码:

clear
reset
unset key
# Make the x axis labels easier to read.
set xtics rotate out
# Select histogram data
set style data histogram
# Give the bars a plain fill pattern, and draw a solid line around them.
set style fill solid border

set title "Intensity of luxA signal for different substances"

set output 'luxA.png'
set terminal png transparent nocrop enhanced font times 18 size 840,640 

set ylabel "Intensität"

set style histogram

plot 'luxA.dat' using 2:xticlabels(1)

以及以下数据:

Name    Value   Color
"SN wt" 1103    blue
"SN ΔΔ" 124.3333333333  blue
"SN -A" 367.3333333333  blue
"SN -B" 147.3333333333  blue
"10nM C100" 325.6666666667  red
"200nM C100"    207.3333333333  red
"300nM C100"    236.6666666667  red
"LB"    180.6666666667  green
"LuxX"  168 green
"only LB"   62  green
"only MQ"   64.6666666667   green
"LB&wt" 65.3333333333   green
"SN LuxX&wt"    73  green

我想根据“颜色”列为每个条形图着色。

如果我可以将不同的组在空间上分组得更紧密一些(组内距离更小,组间距离更大),那就太好了。

(2 个新问题和数据)

新数据(第四行表示误差线(偏差)):

Name    Value   Color   Deviation
"SN wt" 1103    #006400 61.0
"SN ΔΔ" 124.3333333333  #006400 3.21
"SN -CI"    367.3333333333  #006400 25.38
"SN -B" 147.3333333333  #006400 20.74
"10nM C8"   325.6666666667  #0000FF 20.13
"200nM C8"  207.3333333333  #0000FF 28.7
"300nM C8"  236.6666666667  #0000FF 35.91
"1uM BDSF"  596.6666666667  #0000C6 44.12
"10uM BDSF" 545.3333333333  #0000C6 102.01
"15uM BDSF" 547 #0000C6 33.60
"1uM DSF"   596.3333333333  #00008B 98.47
"10uM DSF"  532 #00008B 21
"15uM DSF"  653.6666666667  #00008B 13.65
"LB"    180.6666666667  grey    20.13
"LuxA"  168 grey    20.07
"only LB"   62  grey    9.54
"only MQ"   64.6666666667   grey    20.03   
"LB \\& wt" 65.3333333333   grey    3.79
"SN Lux \\& wt" 73  grey    14.53

--> 有了它,我基本上想实现上面描述的内容,但要加上误差线。下面建议的解决方案适用于颜色,但不适用于我的电脑上的间距(Ubuntu,gnuplot 4.4 patchlevel 2)。它是用方框完成的吗?是否可以将误差线添加到方框中。我有点迷茫,我知道 C 和 Python,但这个 gnuplot 语法让我有点害怕…… :-(

所以我想要: - 根据颜色划分的条形图 - 相同的组(根据颜色)在空间上分组在一起(组内间距小,组间间距大) - 根据第 4 列划分的误差条形图(我不介意它是用方框还是用直方图完成的,只要它能工作就行 :-| ) - mgilson(非常感谢!)的间距解决方案给我一个错误(见下文)。我做错了什么?我完全按照说明使用它……

顺便问一下:您最喜欢的 gnuplot 书籍是什么?

答案1

这可以帮助您入门:

colors='red blue green'
set for [c in colors] style line strstrt(colors,c) lc rgb c
plot 'test.dat' u (column(0)):2:(strstrt(colors,stringcolumn(3))):xtic(1) w boxes lc variable

请注意,我已放弃使用直方图样式。我更喜欢方框 :)。

现在来看看间距。这需要使用内联函数的一些技巧:

idx=0.0
c_old=''
xidx(c)=(idx=idx+(c eq c_old?1.:1.5),cold=c,idx) #increment by 1 if same as old color, otherwise increment by 1.5
set for [c in colors] style line strstrt(colors,c) lc rgb c  #set linestyle for given color
plot 'test.dat' u (xidx(strcol(3))):2:(strstrt(colors,strcol(3))):xtic(1) w boxes lc variable

相关内容