【问题标题】:gnuplot "matrix with image" with a fixed colour for a certain valuegnuplot“带有图像的矩阵”,具有特定值的固定颜色
【发布时间】:2015-01-08 17:22:45
【问题描述】:

使用 gnuplot,我正在使用以下命令绘制存储在文件中的矩阵:

set title "Matrix"
set xrange[-0.5:9.5]
set yrange[9.5:-0.5]
set pm3d map
unset key
unset surface
set term postscript eps enhanced color
set out "matrix.eps"
set palette defined (-1 "#A52A2A", 0 "white", 1 "green" )
splot "matcorrel" matrix with image

矩阵有正值和负值,我想把零值放在白色,正值放在调色板的绿色区域,负值放在棕色。正值大于负值,因此 gnuplot 不会将零放在白色中。

我尝试过使用set cbrange,但我只设法修改了极端颜色,无法修复中心颜色。

有什么想法吗?提前非常感谢您

【问题讨论】:

    标签: matrix colors gnuplot colorbox palette


    【解决方案1】:

    Gnuplot 无法围绕某个值对称地自动缩放。您必须使用例如stats自己确定cbrange:

    set autoscale xfix
    set autoscale yfix
    unset key
    
    set term postscript eps enhanced color
    set out "matrix.eps"
    
    stats "matcorrel" matrix using 3 nooutput
    cbmax = (abs(STATS_min) > abs(STATS_max) ? abs(STATS_min) : abs(STATS_max))
    set cbrange [-cbmax:cbmax]
    set palette defined (-1 "#A52A2A", 0 "white", 1 "green" )
    
    plot "matcorrel" matrix with image
    

    如果您想对正值和负值使用不同的限制,但将零保持为白色,您可以使用

    stats "matcorrel" matrix using 3 nooutput
    set cbrange [STATS_min:STATS_max]
    set palette defined (STATS_min "#A52A2A", 0 "white", STATS_max "green" )
    

    请注意,如果您绘制with image,则不需要使用 pm3d。由于您正在绘制热图,因此您可以直接使用plot

    【讨论】:

    • 感谢您的回答。它工作得很好。是否可以将零设置为白色,并对正值和负值使用不同的限制?
    猜你喜欢
    • 1970-01-01
    • 2012-05-13
    • 2021-04-28
    • 1970-01-01
    • 2016-03-14
    • 1970-01-01
    • 1970-01-01
    • 2012-07-01
    • 2015-03-29
    相关资源
    最近更新 更多