0

我目前正在使用 GracePlot.py 从 python 中绘制带有 xmgrace 的图形,我想在图形中进行文本注释并将它们放在一个框中,以便在网格打开时便于阅读。

有人知道如何使用 GracePlot.py 吗?还是来自 xmgrace GUI?

我使用的代码类似于以下内容:

import GracePlot as xg
import math
from numpy import arange
x=arange(0,10,0.1)
y=[math.exp(-q) for q in x]
grace=xg.GracePlot()
graph=grace[0]
data=xg.Data(x=x,y=y)
graph.plot(data)
graph.text('This should be placed inside a box',5,0.5)
4

1 回答 1

1

我快速浏览了最新的GracePlot模块源代码。看来作者还没有实现制作盒子的能力。

通常,使用 Grace/xmgrace GUI 时,可以在“Drawing Objects”下找到“Box”工具。创建一个框并保存项目,然后在文本编辑器中查看它,因为文件以 ASCII 格式保存。可以找到以下部分:

@with box
@    box on
@    box loctype view
@    box 0.340196078431, 0.691176470588, 0.619607843137, 0.513725490196
@    box linestyle 1
@    box linewidth 1.0
@    box color 1
@    box fill color 1
@    box fill pattern 0
@box def

正如您通过将用于文本创建等的类似块与源代码进行比较可以看到的那样,GracePlot 模块只是为它正在生成的每个事物打印类似的命令。添加制作盒子的功能非常容易。也许你自己有时间?:)

文本功能已实现:

from GracePlot import *
p = GracePlot()
[....]
p.text('Hello, world!', 0.5, 0.4, color=violet, charsize=1.2)

将在 (0.5, 0.4) 处放置一些紫色文本,字符大小为 1.2。

Grace 中的框没有自己的文本,因此为了解决您的问题,您只需将文本对象放在您创建的框上即可。

于 2015-12-07T10:07:51.823 回答