在gnuplot multiplot的透明背景

时间:2012-05-15 18:09:25

标签: 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")

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

提前致谢, FB

1 个答案:

答案 0 :(得分:6)

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

set term png transparent truecolor
set output 'plot.png'
plot sin(x)

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

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

Gnuplot示例:

set terminal postscript enhanced color
set output 'plot.eps'
plot sin(x)

在bash中:

convert plot.eps -rotate 90 plot.png

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

使用矢量图形编辑器(如Inkscape)可能会有一些运气来增加透明度。