xmgrace 中的文本框(最好使用 GracePlot.py)

Text boxes in xmgrace (preferably with GracePlot.py)

我目前正在使用 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)

我快速浏览了最新的GracePlot module source code。看来作者还没有实现制作盒子的能力。

通常,使用 Grace/xmgrace GUI 时,"Box" 工具可以在 "Drawing Objects" 下找到。创建一个盒子并保存项目,然后在文本编辑器中查看它,因为文件以 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 中的框没有自己的文本,因此为了解决您的问题,您只需在您创建的框上放置一个文本对象即可。