如何在 gnuplot 中的颜色图上叠加等高线图?

发布于 2025-01-01 12:29:23 字数 325 浏览 3 评论 0原文

我正在尝试创建 datasetA 的颜色图和 datasetB 的等高线图,这两个图都是从文件中读取的。

以下成功创建了 datasetA 的颜色图:

plot 'valuesA.dat' matrix with image

我可以按照描述绘制轮廓 此处

我怎样才能将这两个图结合起来?

提前致谢!

I'm trying to create a colormap plot of datasetA with a contour plot of datasetB, both of which are read in from files.

The following successfully creates a colormap of datasetA:

plot 'valuesA.dat' matrix with image

I can draw contours as described here.

How can I combine the two plots?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

话少情深 2025-01-08 12:29:23

要回答这个问题,可以在gnuplot技巧中解决。

To answer the question, this is addressed at gnuplot tricks.

并安 2025-01-08 12:29:23

以下是我最终如何对大小为 512x512 的数组执行此操作(例如)。假设我有一个数据文件 A.dat 用于颜色图,B.dat 用于轮廓。

  • 从包含等高线数据的 B.dat 创建一个表,并将其保存到临时文件 temp.dat
  • 使用 A.dat 绘制颜色图,并在单个命令中绘制临时文件 temp.dat 中的等高线。

这是我的代码(为了清晰起见,进行了一些简化):

# Set initial state
reset
set term X11
set palette @MATLAB    # see http://www.gnuplotting.org/matlab-colorbar-with-gnuplot/

# Create a file for contour data
set contour base
set cntrparam levels 25
set isosample 250,250
unset surface
set table "temp.dat"
splot "B.dat" binary array=512x512 format='%double'
unset table


# Plot the final results
set title "Contours and Colormap"
set size square
unset key
set xtics ('0' 0, '0.5' 255, '1.0' 511)   # Change these according to your dimensions
set ytics ('0' 0, '0.5' 255, '1.0' 511)   # Change these according to your dimensions

set cbrange [0.0:1.0]
set xlabel "X (scaled by height)"
set ylabel "Z (scaled by height)"


set terminal png
set output "output.png"
plot "A.dat" binary array=512x512 format='%double' with image, "temp.dat" with lines lt -1

为了看看它是什么样子,我最终使用该代码的脚本版本来生成 这部电影(和其他)用于我的研究!

Here's how I ended up doing it for an array of size 512x512 (for example). Suppose I have a datafile A.dat which is to be used for the colormap and B.dat for the contours.

  • Create a table from B.dat containing the contour data and save it to a temporary file temp.dat.
  • Plot the colormap using A.dat and plot the contour lines from the temp file temp.dat in a single command.

Here's my code (simplified somewhat for clarity):

# Set initial state
reset
set term X11
set palette @MATLAB    # see http://www.gnuplotting.org/matlab-colorbar-with-gnuplot/

# Create a file for contour data
set contour base
set cntrparam levels 25
set isosample 250,250
unset surface
set table "temp.dat"
splot "B.dat" binary array=512x512 format='%double'
unset table


# Plot the final results
set title "Contours and Colormap"
set size square
unset key
set xtics ('0' 0, '0.5' 255, '1.0' 511)   # Change these according to your dimensions
set ytics ('0' 0, '0.5' 255, '1.0' 511)   # Change these according to your dimensions

set cbrange [0.0:1.0]
set xlabel "X (scaled by height)"
set ylabel "Z (scaled by height)"


set terminal png
set output "output.png"
plot "A.dat" binary array=512x512 format='%double' with image, "temp.dat" with lines lt -1

To see what it looks like, I ended up using a scripted version of that code to produce this movie (and others) for my research!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文