这是我的代码:
d1 = Gnuplot.Data(x1,y1, with_="lines lt rgb 'red'", title="1")
d2 = Gnuplot.Data(x2,y2, with_="lines lt rgb 'red'", title="2")
d3 = Gnuplot.Data(x3,y3, with_="lines lt rgb 'red'", title="3")
g.title("aaa")
g('set size 1,0.75')
g('set grid')
g('set term x11 2')
g('set logscale x')
g('set xtics 1,2,110')
g('set xrange [1:110]')
g.plot(d1,d2,d3)
g.hardcopy("aaa.png", terminal='png')
在 gnuplot.py 的临时绘图和硬拷贝中,由于“设置大小 1,0.75”,我在上部有一个大的白色 strip 。 是否有可能避免这种情况并获得与情节完全一样大的数字?
谢谢
请您参考如下方法:
这就是命令 set size 的用途:相对于总 Canvas /图像大小更改绘图大小。要更改图像大小,您必须使用set terminal 命令的size 参数。不幸的是,某些在 gnuplot-py 的 termdefs.py 中定义的终端不支持。正如 termdefs.py 中的注释所说:
"""Terminal definition file.
This module describes the options available to gnuplot's various terminals. For the moment, it only supports a few terminals, but the infrastructure is here to add others as they are needed. ...
svg终端支持size参数:
import Gnuplot
from numpy import *
x1 = arange(1,10)
y1 = arange(1,10)
d1 = Gnuplot.Data(x1,y1, with_="lines lt rgb 'red'", title="1")
g = Gnuplot.Gnuplot()
g.title("aaa")
g('set grid')
g('set logscale x')
g('set xtics 1,2,110')
g.plot(d1)
g.hardcopy("aaa.svg", terminal='svg', size=[800,400])
最灵活的方法是将原始终端定义字符串传递给 gnuplot。然后,行 g.hardcopy... 变成:
g('set terminal pngcairo size 800,400')
g.set_string('output', 'aaa.png')
g.refresh()
g.set_string('output')
这还允许您使用更好的 pngcairo 终端而不是 png 终端。
