【问题标题】:Gnuplot 5: color gradient shading between curvesGnuplot 5:曲线之间的颜色渐变阴影
【发布时间】:2020-02-10 12:56:36
【问题描述】:

这是用 Matplotlib 创建的。是否可以在 Gnuplot 5 中制作相同类型的着色?

【问题讨论】:

    标签: colors gnuplot gradient


    【解决方案1】:

    我不知道 gnuplot 有渐变填充选项,但我可能是错的。 以下是一个“丑陋”的解决方法。您基本上在彼此之上创建 3 个图。您可能需要调整调色板以获得所需的颜色和平滑的过渡。

    1. 将调色板作为背景的虚拟绘图(即颜色框与图形一样大)
    2. 覆盖y>f(x)y>0 上方到x2-axis 以及y<f(x)y<0 下方到x1-axis 的部分。
    3. 再次绘制 f(x) 以查看 f(x) 和轴抽动再次

    编辑: 早期版本的代码使用multiplot。没必要,用set colorbox back即可。但随后set xzeroaxis ls -1 不再可见,改为添加plot 0 w l ls -1

    代码:

    ### filled curve with gradient
    reset session
    
    f(x) = sin(x)/(1+x)
    fabove(x) = f(x)<0 ? 0 : f(x)
    fbelow(x) = f(x)>0 ? 0 : f(x)
    
    set samples 200
    set palette defined (0 "white", 1 "red", 2 "black")
    
    set colorbox back user origin graph 0, graph 0 size graph 1, graph 1
    unset cbtics
    
    set xrange[0:15]
    set xzeroaxis ls -1
    set yrange[-0.2:0.5]
    
    plot fabove(x) w filledcurves x2 fc rgb "white" not, \
         fbelow(x) w filledcurves x1 fc rgb "white" not, \
         f(x) w l lw 2 lc rgb "black", \
         NaN palette, \
         0 w l ls -1
    ### end of code
    

    结果:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-11
      • 2020-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-07
      • 1970-01-01
      相关资源
      最近更新 更多