Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
726 views
in Technique[技术] by (71.8m points)

plot - Gnuplot, pm3d and surfaces

I have a question about pm3d and gnuplot. I want to plot two different surfaces with two different pm3d styles. How can i do that? Is it possible? I tried with multiplot but in that case surfaces will overlap and i cannot rotate the graph. Any help will be appreciated, thank you!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here is an example with pseudo data:

reset 
set xrange[0:1]
set yrange[0:1]
set cbrange[0:1]
set palette defined (0 'green', 1 'red', 1 'blue', 2 'white')
set isosamples 100
set samples 100
set pm3d depthorder
set view 60,335
splot '++' using 1:2:2:(0.5*$2) with pm3d title 'red -> green',
      '++' using 1:2:1:(0.5*(1+$1)) with pm3d title 'blue -> white'

Result: enter image description here

To use data instead of these pseudo data generated by '++' you can use stats to determine the data ranges and scale the surface colors accordingly to [0:0.5] for one, and to [0.5:1] for the other.

This concept with the different color ranges to incorporate two palettes in one does work only for data files (including pseudo data files). To plot two spheres beneath each other with different colors, one can first produce a data file, which is later used for pm3d plotting:

reset 
# generate the sphere data
set samples 100
set isosamples 100
set parametric
set urange[0:2*pi]
set vrange[0:pi]
set table 'spheres.dat'
r = 0.25
splot r*cos(u)*sin(v),r*sin(u)*sin(v),r*cos(v) with lines
unset table
unset parametric

# plot the generated data set
set xrange[-1:1]
set yrange[-1:1]
set cbrange[-1:3]
set palette defined (0 'black', 1 'green', 1 'black', 2 'red')

set pm3d depthorder
unset colorbox
unset key
set ticslevel 0
set view 19,34
splot 'spheres.dat' using ($1-0.5):2:3:($3/r) with pm3d, 
      '' using ($1+0.5):2:3:($3/r + 2) with pm3d

The result is enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...