【问题标题】:Gnuplot mappingGnuplot 映射
【发布时间】:2020-05-12 09:35:30
【问题描述】:

我在尝试用 gnuplot 中的矢量场绘制一些 3d 映射时遇到问题,问题是,我想绘制梯度图,然后在地图上方绘制一个矢量场。我有这个代码:

####
reset
clear

set title '{/:Bold Retrato de fase b=1.120}' font ",18"
set xlabel "{/:Bold x1}"
show xlabel
set xrange[0:1]

set ylabel "{/:Bold x2}" 
show ylabel
set yrange [0:1]
set multiplot
set multiplot layout 1,1
set origin 0,0

set palette defined ( 0 'white', 1 'green', 3 'blue' )
set pm3d map
set pm3d depthorder hidden3d

set key top left
set key Left
set samples 100,100
set style increment default
set style fill transparent

set arrow from 1,0 to 0,0.7692307692 nohead front
set arrow from 0,1 to 0.7692307692,0  nohead front

set object circle at graph 0,1 radius char 1 front \
    fillcolor rgb 'black' fillstyle solid noborder
set object circle at graph 1,0 radius char 1 front \
    fillcolor rgb 'black' fillstyle solid noborder

set pm3d
splot  "phase_portrait.txt" u 1:2:5 notitle  w pm3d
unset pm3d

plot "arrows.txt" u 1:2:3:4 w vectors filled head lc rgb 'black' notitle
####

这些是 phase_portrait.txt 存档的几行(每次 x 更改时我都会在存档中放置一个空白行):

0.000000     0.000000    0.000000    0.000000    0.000000 
0.000000     0.010000    0.000000    0.022222    0.117624 
0.000000     0.020000    0.000000    0.022222    0.230543 
0.000000     0.030000    0.000000    0.022222    0.338829 
0.000000     0.040000    0.000000    0.022222    0.442552 
0.000000     0.050000    0.000000    0.022222    0.541785 
0.000000     0.060000    0.000000    0.022222    0.636598 
0.000000     0.070000    0.000000    0.022222    0.727063 

这些来自arrows.txt:

0.000000     0.000000    0.000000    0.000000  
0.000000     0.100000    0.000000    0.022222  
0.000000     0.200000    0.000000    0.022222  
0.000000     0.300000    0.000000    0.022222  
0.000000     0.400000    0.000000    0.022222  
0.000000     0.500000    0.000000    0.022222  
0.000000     0.600000    0.000000    0.022222  
0.000000     0.700000    0.000000    0.022222  

无论我做什么,向量的输出都不会匹配梯度图。 我添加了输出的图像:

【问题讨论】:

  • 能不能给几行phase_portrait.txt加广告?
  • 请添加图片。好吧,您正在创建两个单独的图,一个 splot 和一个 plot。所以你只会看到后一个。如果您显示生成的图表以及一些示例数据线,我们将能够为您提供帮助。
  • 你的代码真的完整吗?我怀疑您在此处显示的此代码会产生此结果。你在用multiplot吗?
  • theozh,嗨,是的,我正在使用 multiplot,这是完整的代码:

标签: gnuplot vector-graphics 3d-mapping


【解决方案1】:

这里不需要使用multiplot,也不需要使用splot。 下面的最小示例生成了一些测试数据用于说明。 我希望您可以根据需要调整代码。

代码:

### overlay of map and vectors
reset session

# create some test data for map
set samples 100
set isosamples 100
set table $Data
    plot '++' u 1:2:($1*$2) w table
unset table

# create some test data for vectors
set samples 10
set isosamples 10
set table $Vectors
    plot '++' u 1:2:($1/sqrt($1**2+$2**2)):($2/sqrt($1**2+$2**2)) w table
unset table

set xrange[-5:5]
set yrange[-5:5]
set palette defined ( 0 'white', 1 'green', 3 'blue' )

plot $Data u 1:2:($1*$2) w image, \
     $Vectors u 1:2:3:4 w vec lc rgb "black" notitle
### end of code

结果:

【讨论】:

  • 感谢我尝试一下
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-11
  • 1970-01-01
  • 2019-02-26
相关资源
最近更新 更多