在gnuplot multiplot的透明背景

Fra*_*kBr 6 python gnuplot

我想在我的gnuplot数字中获得透明背景.我编码到现在为止:

#! /usr/bin/python

from numpy import *
import Gnuplot as gp
import Gnuplot.funcutils

x = (1,2,3)
y=(2,4,5)
x1 = (3,6,8)
g = gp.Gnuplot()
g("set terminal svg size 200,400")
g("set output 'filename.svg'")
g("unset xtics")
g("unset ytics")
g("set multiplot layout 3,1 title 'Title here'")
g("set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb '#ff0000'      behind")
#First
g("set tmargin 2")
g("set title 'Plot'")
g("unset key")
d = gp.Data(x,y,with_="lines")
g.plot(d)
#Secon
g("set title 'Plot2'")
g("unset key")
d1 = gp.Data(x1,y,with_="lines")
g.plot(d1)
#Third
g("set title 'Plot3'")
g("unset key")
d2 = gp.Data(y,x,with_="lines")
g.plot(d2)
g("unset multiplot")
Run Code Online (Sandbox Code Playgroud)

我有一个红色的屏幕,但只是第三个情节.(是的,我必须更改rgb组合以获得透明的背景颜色.但是,它是什么?)

在此先感谢,FB

and*_*ras 6

Gnuplot可以直接输出透明背景,但不能输出所有格式.例如,这可以为.png完成:

set term png transparent truecolor
set output 'plot.png'
plot sin(x)
Run Code Online (Sandbox Code Playgroud)

transparent处理背景的透明度,以及truecolor透明对象/绘图填充的透明度.

我可以从gnuplot获得透明背景的另一种方法是输出.eps并将其转换为.png或支持透明度的栅格格式.

Gnuplot示例:

set terminal postscript enhanced color
set output 'plot.eps'
plot sin(x)
Run Code Online (Sandbox Code Playgroud)

在bash中:

convert plot.eps -rotate 90 plot.png
Run Code Online (Sandbox Code Playgroud)

生成的.png具有透明背景,而.eps则没有.这可能与imagemagick处理透明度的方式有关.我将.svg转换为.png也不会发生同样的情况.它仍然有一个白色的背景.

您可能会使用矢量图形编辑器(如Inkscape)来增加透明度.

  • Gnuplot 可以在 `png` 文件中进行透明处理。`set terminal png transparent truecolor` 应该可以解决问题(transparent 处理背景,而 truecolor 处理任何其他可能透明的对象)——或者使用 pngcairo——`set term pngcairo transparent`。在 gnuplot 中完成所有操作可能会产生比您从转换中获得的更清晰的图像(尤其是文本) (2认同)