在gnuplot中绘制多个pm3d曲面,每个曲面都有自己的调色板 [英] Plotting multiple pm3d surfaces each having its own palettes in gnuplot

查看:55
本文介绍了在gnuplot中绘制多个pm3d曲面,每个曲面都有自己的调色板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上想做的事情与该问题的解决方案基本相同

What I basically want to do is basically the same as the solution to this question Gnuplot 5.2 splot: Multiple pm3d palette in one plot call , but which works with pm3d. If you read the comment to that answer, the answerer said that the solution does not work if he used pm3d. Also, would it be possible to define the palette in a simpler manner, such as set palette defined ()?

解决方案

The development branch of gnuplot supports multiple named palettes. The method shown here, however, works on earlier versions of gnuplot also. It uses the fill style to provide a color (rather than the pm3d palette), and shows how to define the fill colors so that they mimic set palette defined(). This demo constructs only one mapping, but you could define several mappings each with its own array of colors and mapping function to use them.

This demo is extracted from the full demo for named palettes in the development branch. If you are interested you can find the full demo here: Version 5.5 named palette demo

#
# Demonstrate construction and use of a separate palette
# Ethan A Merritt - May 2020
#
# Method 1:
#       The first method works also in 5.2 but requires "lc rgb variable"
#       rather than the more natural "fillcolor rgb variable".
#       "set pm3d interpolate" breaks the color mapping of this method

#
# This creates a palette equivalent to
#       set palette defined (0 "dark-blue", 1 "white")
#
array blues[256]
do for [i=1:256] {
    blues[i] = int( (0x7f + (i-1)/(255.) * 0xffff80) );
}

#
# This is the equivalent of
#       set cbrange [-1:1]
blues_min = -1
blues_max = 1

#
# This function maps z onto a palette color
#
blues(z) = (z <= blues_min) ? blues[1] \
         : (z >= blues_max) ? blues[256] \
         : blues[ floor(255. * (z-blues_min)/(blues_max-blues_min)) + 1]

foo(x,y) = sin(x*y)

set samples 41
set isosamples 41
unset colorbox
set cbrange [-1:1]
set xrange [0:5]; set urange [0:5]
set yrange [0:5]; set vrange [0:5]

set title "Use hand-constructed 'blues' palette via rgb variable"

splot '++' using 1:2:(foo($1,$2)):(blues(foo($1,$2))) with pm3d fillcolor rgb variable \
           title "pm3d using 1:2:3:4 with pm3d fillcolor rgb variable"

这篇关于在gnuplot中绘制多个pm3d曲面,每个曲面都有自己的调色板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆