在gnuplot中绘制多个pm3d表面,每个表面都有自己的调色板

如何解决在gnuplot中绘制多个pm3d表面,每个表面都有自己的调色板

我基本上想做的事情与该问题的解决方案基本相同 Gnuplot 5.2 splot: Multiple pm3d palette in one plot call ,但可用于pm3d。如果您阅读了对该答案的评论,则回答者说,如果他使用pm3d,则该解决方案将不起作用。另外,是否可能以更简单的方式定义调色板,例如set palette defined ()

解决方法

gnuplot的开发分支支持多个命名调色板。但是,此处显示的方法也适用于早期版本的gnuplot。它使用填充样式来提供颜色(而不是pm3d调色板),并显示如何定义填充颜色以使其模仿set palette defined()。该演示仅构建一个映射,但是您可以定义多个映射,每个映射都有自己的颜色数组和映射函数以使用它们。

此演示摘自开发分支中命名调色板的完整演示。如果您有兴趣,可以在这里找到完整的演示: 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"

enter image description here

,

也许您可以用set palette defined来定义调色板,但是据我所知调色板有256个色阶,您可能必须将3个调色板组合成1个调色板,并且您将失去“颜色分辨率”。 。老实说,我还没有详细考虑这个问题。

我再次检查了您引用的代码...显然,将在“技巧”中添加一行。然后您可以绘制with pm3d

set pm3d depthorder 

代码:(此处略有修改的代码:https://stackoverflow.com/a/57501649/7295599

### multiple "palettes" within one splot command
reset session

set samples 101,101
set isosamples 101,101 

f(x,y) = sin(1.3*x)*cos(0.9*y)+cos(.8*x)*sin(1.9*y)+cos(y*.2*x)
set table $Data01
    splot f(x,y)
unset table

g(x,y) = y
set table $Data02
    splot g(x,y)
unset table

h(x,y) = 0.5*x
set table $Data03
    splot h(x,y)
unset table

Zmin = -3
Zmax= 3

set xrange[-5:5]
set yrange[-5:5]
set zrange[Zmin:Zmax]
set hidden3d
set angle degree

Frac(z) = (z-Zmin)/(Zmax-Zmin)
# MyPalette01
Red01(z) = 65536 * ( Frac(z) > 0.75 ? 255 : int(255*abs(2*Frac(z)-0.5)))
Green01(z) = int(255*sin(180*Frac(z)))*256
Blue01(z) = int(255*cos(90*Frac(z)))
MyPalette01(z) =  Red01(z) + Green01(z) + Blue01(z) 

# MyPalette02
Red02(z)   = 65536 * int(255*Frac(z))
Green02(z) = 256 * (Frac(z) > 0.333 ? 255 : int(255*Frac(z)*3))
Blue02(z)  = (Frac(z) > 0.5 ? 255 : int(255*Frac(z)*2))
MyPalette02(z) =  Red02(z) + Green02(z) + Blue02(z) 

# MyPalette03
Red03(z)   = 65536 * (Frac(z) > 0.5 ? 255 : int(255*Frac(z)*2))
Green03(z) = 256 * (Frac(z) > 0.333 ? 255 : int(255*Frac(z)*3))  
Blue03(z)  = int(255*Frac(z)) 
MyPalette03(z) =  Red03(z) + Green03(z) + Blue03(z) 

set pm3d depthorder
unset colorbox 

set view 44,316
splot $Data01 u 1:2:3:(MyPalette01($3)) w pm3d lc rgb var notitle,\
      $Data02 u 1:2:3:(MyPalette02($3)) w pm3d lc rgb var notitle,\
      $Data03 u 1:2:3:(MyPalette03($3)) w pm3d lc rgb var notitle
### end of code

结果:

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive&gt; show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res