样本,等值样本以及它们如何影响轮廓线 [英] Samples, isosamples, and how they affect contour lines

查看:89
本文介绍了样本,等值样本以及它们如何影响轮廓线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果没有同时设置 samples isosamples ,则gnuplot生成的轮廓线可能看起来很奇怪(意外)。适当的值。我费了好几个小时才能弄清楚设置样本设置isosamples 对轮廓线的外观有何影响我观察到,将两者都设置为足够大的值将生成美观的轮廓。仍然,我想了解这是如何工作的。


  1. 设置样本之间有什么区别在轮廓线的背景下设置等值样本

  2. 如何设置样本影响轮廓线的生成?

  3. 设置等值样本如何影响轮廓线的生成?

例如,考虑以下简单情况:

 未设置表面
设置轮廓
设置cntrparam级别离散10、20
设置样本250、2
设置isosamples 2,250
设置视图
散点图x ** 2 + y ** 2

要生成正确的轮廓线,您似乎需要将 samples 的第一个参数和 isosamples 的第二个参数设置为足够大的值。但是,将 samples 的第二个参数和 isosamples 的第一个参数设置为尽可能小的值不会有任何危害。这不是完全直观的。那么,这是如何工作的?

解决方案

首先,讨论什么样本 isosamples 用于设计。最好是在查看实际图而不是等高线图时。



样本用于设置样本数。沿绘制范围内的轴进行功能评估。对于绘图(3-D图像),您可以在独立的方向x和y上控制样本。这是一个示例,其中x方向只有4个求值,而y方向只有200个求值:

 重置
设置xrange [-10:10]
设置yrange [-10:10]
设置xlabel'X'
设置ylabel'Y'
设置样本4,200
散点图x ** 2 + y ** 2

在以下2张图片中,请注意沿x方向,该函数仅被评估4次,并且在它们之间绘制直线。沿y方向评估了200次,看起来像是平滑曲线。请注意,在两个方向上均精确绘制了10条线。



朝x轴方向看:



向y轴方向看:






因此,在每个轴方向上绘制了10条线,因为x和y方向上的等值线的默认值为10。我们可以随意更改。让我们在两个方向上增加样本以获得平滑的曲线,但演示等值样本。

  reset 
set xrange [-10: 10]
设置yrange [-10:10]
设置xlabel'X'
设置ylabel'Y'
设置样本200,200
设置isosamples 4,12
splot x ** 2 + y ** 2

请注意两个方向上的平滑曲线。沿着x轴,只有4个点沿y轴绘制表面曲线,沿着y轴有12个点平行于x轴绘制表面曲线。








以上示例演示了设置样本设置等值样本的主要目的。它们仅间接影响轮廓。在您的情况下,您只对轮廓图感兴趣,甚至不显示曲面图。关于gnuplot如何绘制轮廓的一个线索在于它如何解释如何使用谨慎的数据绘制轮廓。



Gromacs:


为了绘制轮廓,数据应组织为网格数据。在
这样的文件中,列出了一个y等值线的所有点,然后列出了下一个y等值线的所有
点,依此类推。一条空白行(一行
除空格外不包含其他字符,回车和/或
a换行符)将一个y-等值线与下一个y-等值线分隔。


根据这种解释,gnuplot似乎更喜欢选择x值并绘制y等值线。然后,我们可以推断出,当gnuplot从函数绘制轮廓时,它将选择x值并绘制y等值线。因此,有许多x样本和许多y等值线会绘制高分辨率的轮廓,而y样本和x等值线是不相关的(如果您不绘制表面)。


Contour lines generated by gnuplot can look pretty strange (unexpected) if you do not set both samples and isosamples to appropriate values. I struggled for hours to find out how exactly set samples and set isosamples affect the appearance of contour lines, however, all I observed is that setting both to sufficiently large values will generate good-looking contours. Still, I want to understand how exactly this works.

  1. What is the difference between set samples and set isosamples in the context of contour lines?
  2. How does set samples affect the generation of contour lines?
  3. How does set isosamples affect the generation of contour lines?

For example, consider the following simple case:

unset surface
set contour
set cntrparam levels discrete 10, 20
set samples 250, 2
set isosamples 2, 250
set view map
splot x**2 + y**2

To generate correct contour lines, it appears you need to set the first parameter of samples and the second parameter of isosamples to sufficiently large values. However, setting the second parameter of samples and the first parameter of isosamples to the smallest possible value does no harm. This is not exactly intuitive. So how does this work?

解决方案

First, a discussion on what samples and isosamples where designed to do. This is best when viewing the actual plot and not the contour map.

samples is used to set the number of function evaluations along an axis in the range being plotted. For splot (3-D images), you can control samples in both independent directions x and y. Here is a sample where the x-direction only has 4 evaluations and the y-direction has 200:

reset
set xrange [-10:10]
set yrange [-10:10]
set xlabel 'X'
set ylabel 'Y'
set samples 4,200
splot x**2+y**2

In the following 2 images note that along the x-direction, the function is only evaluated 4 times and straight lines are drawn between them. Along the y-direction, it is evaluated 200 times and it looks like 'smooth' curves. Note that in both directions, exactly 10 lines are drawn. I will get to that below while discussing isolines.

Looking toward x-axis:

Looking toward y-axis:


So, 10 lines in each axis direction are drawn because the default value for isolines in both x and y directions is 10. We can change this at will. Lets increase samples in both directions for a nice smooth curves but demonstrate isosamples.

reset
set xrange [-10:10]
set yrange [-10:10]
set xlabel 'X'
set ylabel 'Y'
set samples 200,200
set isosamples 4,12
splot x**2+y**2

Note the nice smooth curves in both directions. Along the x-axis, there are only 4 points where, along the y-axis, the surface curves are drawn and along the y-axis, there are 12 points where surface curves are drawn parallel to the x-axis.


The above examples demonstrate the primary purpose of set samples and set isosamples. They only indirectly affect contours. In your case, you are only interested in the contour map without even displaying the surface plot. A clue as to how gnuplot plots contours is in its explanation of how contours can be drawn with discreet data.

Gromacs:

In order to draw contours, the data should be organized as "grid data". In such a file all the points for a single y-isoline are listed, then all the points for the next y-isoline, and so on. A single blank line (a line containing no characters other than blank spaces and a carriage return and/or a line feed) separates one y-isoline from the next.

From this explanation, gnuplot seems to prefer to pick an x value and draw a y-isoline. We can deduce then that when gnuplot draws contours from functions, that it picks x values and draws y-isolines. Therefore having many x samples and many y isolines draws hi resolution contours while the y samples and the x isolines are irrelevant (if you are not drawing the surface).

这篇关于样本,等值样本以及它们如何影响轮廓线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆