gpt4 book ai didi

gnuplot - 如何改进 Gnuplot 中渐变和填充元素的渲染?

转载 作者:行者123 更新时间:2023-12-01 03:40:38 28 4
gpt4 key购买 nike

我注意到 Gnuplot 在处理填充元素时会产生丑陋的人工制品。

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

palette

另一个例子是使用 filledcurves 时从 ASCII 文件中的点定义的两条曲线之间。在这种情况下,您可以看到线条之间不是真正的实心填充,而是填充了许多 strip ,这些 strip 只有在放大很多后才会变得明显,但是在将图像光栅化为 png 或相似的:

strips

这似乎在终端上是独立的。我试过 postscrip , pdfcairo甚至 tikz .有什么可以做的来改善这一点,或者这是 Gnuplot 的一个硬限制?

最佳答案

不幸的是,当您有两个填充的多边形相互接触时,这是由于文档查看器中的抗锯齿造成的伪影。 filledcurves 会发生这种情况绘图样式,由许多四边形的填充区域组成,以及 pm3d样式(正如您在颜色框中看到的那样,它显示了相同的工件)。也可以看看
problematic Moire pattern in image produced with gnuplot pm3d and pdf output.对于一个具体的演示案例。

有一种解决方法,但是非常麻烦。你必须用一些脚本生成一个填充的多边形对象,填充它,使用 stats要确定范围,请绘制一个空图(参见例如 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) )。

我假设你有一个包含三列的数据文件,你可以用

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

使用以下非常粗略的python脚本
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='')

您可以绘制填充曲线
# 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

那还没有解决锯齿状颜色框的问题:(

关于gnuplot - 如何改进 Gnuplot 中渐变和填充元素的渲染?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31184103/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com