Gnuplot: how to have some space between axes and pm3d map plot

爱⌒轻易说出口 提交于 2019-12-10 17:13:12

问题


Here is my code:

f(x,y)=sin(1.3*x)*cos(.9*y)+cos(.8*x)*sin(1.9*y)+cos(y*.2*x)
set size square
set xrange [-5:5]
set yrange [-5:5]
set contour base
set cntrparam level incremental -3, 0.5, 3
set palette rgbformulae 33,13,10
set pm3d map
set isosample 250, 250
unset key
set lmargin at screen 0.05
set rmargin at screen 0.9
set bmargin at screen 0.05
set tmargin at screen 0.9
splot f(x,y) with pm3d

This is the figure:

How can I have some space between axes and the actual plot like this one:


回答1:


For data sets one can use set offsets together with set autoscale fix to achieve exactly this. So one option is to plot you data to a file (set table 'tmp.txt'; splot f(x,y) w l; unset table`) and then plot that file as data.

Another option would be to redefine your function to return 1/0 for samples outside a certain range.

What I found to be the most elegant way (at least what I found), is to use parametric mode and use smaller urange and vrange than xrange and yrange:

reset
f(x,y)=sin(1.3*x)*cos(.9*y)+cos(.8*x)*sin(1.9*y)+cos(y*.2*x)
set size square

set contour base
set cntrparam level incremental -3, 0.5, 3
set palette rgbformulae 33,13,10
set pm3d map
set isosample 250, 250
unset key
set lmargin at screen 0.05
set rmargin at screen 0.9
set bmargin at screen 0.05
set tmargin at screen 0.9

# 5% margin on each side
m = 1.05
set xrange [-m*5:m*5]
set yrange [-m*5:m*5]
set urange [-5:5]
set vrange [-5:5]
set parametric

splot u,v,f(u,v) with pm3d

with the result (with 4.6.4):



来源:https://stackoverflow.com/questions/23294416/gnuplot-how-to-have-some-space-between-axes-and-pm3d-map-plot

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!