Reputation: 187
I'm trying to create something similar to these plots:
I have the surface plot and what I would like to put under it being plotted separately for now:
I've tried plotting the 2D image as a binary plot in the surface plot, but each pixel is interpreted as a whole unit in the coordinate system, which is incorrect, and it ends up duplicating the coordinate axes and plot title, etc. As well, gnuplot's xyplane isn't necessarily at z=0, so just plotting using splot normally with a z value of 0 also doesn't do what I want.
These are my plotting files so far:
2D Scatterplot:
set terminal png enhanced size 8000, 4800 truecolor font "arial,60"
set encoding utf8
set output outfile
set autoscale fix
set border lw 3
set style fill transparent solid 0.075 noborder
set style circle radius 0.03
set title plotTitle
plot sample1 u 1:2 w circles notitle,\
sample2 u 1:2 w circles notitle,\
$ContourTable w lines lw 6 lc rgb 'black' notitle,\
keyentry w circles fill solid 1.0 noborder lc 1 title "ω_1",\
keyentry w circles fill solid 1.0 noborder lc 2 title "ω_2"
Surface Plot:
set terminal png enhanced size 8000, 4800 truecolor font "arial,60"
set encoding utf8
set output outfile
set autoscale fix
set border lw 3
set title plotTitle
set isosamples 100
set pm3d at s explicit hidden3d
unset hidden3d
set palette model RGB define (1 "dark-violet", 2 "#009e73")
splot pdfFile u 1:2:3:4 w pm3d lc rgb "black"
Upvotes: 1
Views: 623
Reputation: 15093
Although the base plane chosen automatically by gnuplot may be non-obvious, it is quite possible to set it wherever you like using the command set xyplane at <z-value>
. Here is an example adapted from the on-line demo set (3rd plot in random.dem)
Not all plot styles used by 2D plots are also supported in 3D, but many of them are.
#
# The surface plot shows a two variable multivariate probability"
# density function. On the x-y plane are some samples of the random"
# vector and a contour plot illustrating the correlation, which in"
# this case is zero, i.e. a circle. (Easier to view in map mode.)"
#
nsamp = 50
# Generate N random data points.
set print $random
do for [i=1:nsamp] {
print sprintf("%8.5g %8.5g", invnorm(rand(0)), invnorm(rand(0)))
}
unset print
#
unset xlabel
unset ylabel
unset zlabel
set parametric
tstring(n) = sprintf("%d random samples from a 2D Gaussian PDF with\nunit variance, zero mean and no dependence", n)
set title tstring(nsamp)
unset key
set hidden3d
set contour
set view 68, 28, 1, 1
set cntrparam levels discrete 0.1
unset clabel
set xrange [-3:3]
set yrange [-3:3]
set zrange [-0.2:0.2]
set ztics 0,0.05
set urange [-3:3]
set vrange [-3:3]
set isosamples 30
BASE = -0.2
set xyplane at BASE
splot u,v,( 1/(2*pi) * exp(-0.5 * (u**2 + v**2)) ) with line lc rgb "black", \
$random using 1:2:(BASE) with points pointtype 7 lc rgb "slategray" nocontour
Upvotes: 0
Reputation: 25749
Maybe something like this? Maybe needs to be adapted to your data and further fine tuned.
Code:
### surface plot with contour
reset session
GaussW3D(x,y,x0,y0,A,FWHM) = A * exp(-(x-x0)**2/(2*(FWHM/(2*sqrt(2*log(2))))**2)) *\
exp(-(y-y0)**2/(2*(FWHM/(2*sqrt(2*log(2))))**2))
set samples 40
set isosamples 40
f(x,y) = GaussW3D(x,y,4,4,1,5) + GaussW3D(x,y,0,0,1.5,3)
set contour base
set cntrparam levels 10
set hidden3d
set xyplane at -2
set ztics 0.5
splot sample [-4:10][-7:10] '++' u 1:2:(f(x,y)) w l
### end of code
Result:
Upvotes: 1