如何在Gnuplot中改善渐变和填充元素的渲染? [英] How to improve the rendering of gradients and filled elements in Gnuplot?

查看:224
本文介绍了如何在Gnuplot中改善渐变和填充元素的渲染?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经注意到,当处理填充元素时,Gnuplot会产生丑陋的假象.

I have noticed that Gnuplot produces ugly artefacts when dealing to filled elements.

一个实例在下图的调色板中:

One instance is in the palette of the next figure:

另一个示例是在从ASCII文件中的点定义的两条曲线之间使用filledcurves时.在这种情况下,您可以看到该区域不是由线之间真正的实心填充,而是由条带数填充,这些条带仅在放大很多倍后才变得明显,但是在将图像光栅化为png或png时具有非常大的影响.相似:

Another example is when using filledcurves between two curves defined from points in ASCII files. In this case, you can see that rather than a real solid fill between the lines, the area is filled with number of strips, that only become apparent after zooming quite a bit, but that has very strong impact when rastering the image to png or similar:

这似乎在终端上是独立的.我已经尝试过postscrippdfcairo甚至tikz.有什么可以改善的方法吗?或者这是Gnuplot的硬限制吗?

This seems to be independent on the terminal. I have tried postscrip, pdfcairo and even tikz. Is there anything that can be done to improve this, or is this a hard limitation of Gnuplot?

推荐答案

不幸的是,当您有两个填充的多边形相互接触时,由于文档查看器中的抗锯齿,这是一种假象.这是由filledcurves绘制样式(它构成许多四边形的填充区域)以及pm3d样式(如在色盒中看到的,显示相同的工件)组成的.也可以看看 使用gnuplot pm3d和pdf输出生成的图像中的问题莫尔条纹.用于具体的演示案例.

Unfortunately, this is an artifact due to antialiasing in the document viewer when you have two filled polygons touching each other. This happens with the filledcurves plotting style, which composes the filled area of many quadrangles, as well as with the pm3d style (as you can see in the colorbox, which shows the same artifacts). See also problematic Moire pattern in image produced with gnuplot pm3d and pdf output. for a concrete demo case.

有一个解决方法,但是非常麻烦.您必须使用某些脚本生成一个填充的多边形对象,对其进行填充,然后使用stats确定范围,绘制一个空图(请参见例如 Gnuplot-如何获得一个没有点的图形(我只想拥有轴,标题以及x和y标签)).

There is a workaround, which however is very cumbersome. You must generate a filled polygon object with some script, fill that, use stats to determine the ranges, plot an empty plot (see e.g. Gnuplot - how can I get a figure with no point on it ? (I want to have only the axes, the title and the x- and y- labels)).

我假设您有一个包含三列的数据文件,并且可以使用

I assume, that you have a data file with three columns, and you would plot them with

plot 'test.dat' using 1:2:3 with filledcurves

使用以下非常粗糙的python脚本

Using the following very crude python script

from __future__ import print_function
from numpy import loadtxt
import sys

M = loadtxt(sys.argv[1])
print('set object 1 polygon ', end='')
for i in range(0,len(M)):
    if (i == 0):
        print('from {0},{1} '.format(M[i][0], M[i][1]), end='')
    else:
        print('to {0},{1} '.format(M[i][0], M[i][1]), end='')
for i in range(len(M)-1,-1,-1):
    print('to {0},{1} '.format(M[i][0], M[i][2]), end='')

您可以使用以下方式绘制填充曲线

You can plot the filled curve with

# determine the autoscaling ranges
set terminal push
set terminal unknown
plot 'test.dat' using 1:2, '' using 1:3
set terminal pop

set xrange [GPVAL_X_MIN:GPVAL_X_MAX]
set yrange [GPVAL_Y_MIN:GPVAL_Y_MAX]
eval(system('python script.py test.dat'))
set object 1 polygon fillstyle solid noborder fillcolor rgb 'red'
plot NaN notitle

那还不能解决锯齿状颜色盒的问题:(

That, doesn't yet cover the problem with the jagged colorbox :(

这篇关于如何在Gnuplot中改善渐变和填充元素的渲染?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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