gnuplot:如何将绘图区域设置为数据的像素完美表示

发布于 2025-01-07 05:25:51 字数 322 浏览 0 评论 0原文

别名问题?

我很难让 GNUplot 正确渲染我的一些数据。基本上我有一些 2D 高度图数据(例如 512 x 128 数据点),并且希望能够以“像素完美”方式绘制此数据(即每个数据点一个像素)。不幸的是,目前,由于像素数量略大于数据点数量,我得到了伪影(参见插图)。我知道我可以使用以下方法设置输出的总大小:

set terminal png size 800,400

但是有没有办法只设置绘图区域大小(以像素为单位)?

谢谢!

aliasing issue?

I'm having difficulty getting GNUplot to properly render some of my data. Basically I have some 2D heightmap data (for example 512 x 128 data points) and would like to be able to plot this in a "pixel perfect" fashion (i.e. one pixel per data point). Unfortunately at the moment, I'm getting artefacts (see inset) due to the number of pixels being slightly larger than the number of data points. I know I can set the total size of the output using:

set terminal png size 800,400

but is there a way to set just the plot area size in pixels?

Thanks!

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

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

发布评论

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

评论(1

月依秋水 2025-01-14 05:25:51

在 lua/TikZ 终端的帮助下(有一个选项plotsize),建议删除绘图边距,以便绘图填充整个画布。

set lmargin 0
set rmargin 0
set tmargin 0
set bmargin 0
set terminal png size 512,128
set out 'out.png'
# a checkerboard pattern to test the plot results for errors
f(x,y)=( (x<=0) || (x>=63) || (y<=0) || (y>=63) ) ? 0.5 : ((x+y)%2==0)?0:1
# the 'map' file contains only coordinates.
plot[-1:63][0:64] 'map' u 1:2:(f($1,$2)) with image
unset out

然而,这有一个缺点,就是你不会有tic标签等等。您当然可以自己计算边距值,以便它们最终与绘图大小相匹配:

set lmargin at screen 0.25

例如使用。

无论如何,我还建议尽可能使用矢量图形。

From the help of the lua/TikZ terminal (there is an option plotsize) it is suggested to remove the plot margins so that plot fills the whole canvas.

set lmargin 0
set rmargin 0
set tmargin 0
set bmargin 0
set terminal png size 512,128
set out 'out.png'
# a checkerboard pattern to test the plot results for errors
f(x,y)=( (x<=0) || (x>=63) || (y<=0) || (y>=63) ) ? 0.5 : ((x+y)%2==0)?0:1
# the 'map' file contains only coordinates.
plot[-1:63][0:64] 'map' u 1:2:(f($1,$2)) with image
unset out

However, this has the drawbacks that you will not have tic labels and so on. You can of course calculate values for the margins yourself, so that they match with the plot size in the end: use

set lmargin at screen 0.25

for example.

Anyway, I would also recommend going for vector graphics whenever possible.

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