【问题标题】:gnuplot fill area under curve alternativelygnuplot 交替填充曲线下的区域
【发布时间】:2018-04-17 09:16:24
【问题描述】:

我在生成一个在负值和正值之间振荡的数据集图(线为 sin 或 cos)时遇到了一些困难。我的目标是用交替的颜色填充曲线下的区域:蓝色的负区域和红色的正区域。更准确地说,我想填充曲线和 x 轴之间的区域。到目前为止,我设法使用交替颜色(蓝色为负,红色为正)绘制曲线:

set palette model RGB defined ( 0 'red', 1 'blue' )
unset colorbox
plot 'data.set' u 1:2:( $2 < 0.0 ? 1 : 0 ) w lines lt 1 lw 4 palette

很遗憾,如果我将 w lines 替换为 filledcurves,我将无法获得替代填充。如何做到这一点?

干杯

【问题讨论】:

    标签: gnuplot


    【解决方案1】:

    如果我正确理解了这个问题,你可以试试这个:

    plot '+' using 1:(0):(sin($1)) w filledc below, \
         '+' using 1:(0):(sin($1)) w filledc above
    

    告诉gnuplot 使用上方和下方位置填充两条曲线(sin(x)0)之间的区域。还有另一种解决方案:

    plot '+' using 1:(sin($1) > 0 ? sin($1):0) w filledcurves y1, \
         '+' using 1:(sin($1) < 0 ? sin($1):0) w filledcurves y2
    

    结果是:

    重要部分是指filledcurvesoptions 部分。查看更多详情 herehere

    【讨论】:

    • 这正是我想要的!谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-15
    • 2020-07-02
    • 2018-11-01
    • 2021-12-23
    • 2014-02-07
    • 1970-01-01
    相关资源
    最近更新 更多