1

是否可以使用乳胶文本创建 chaco 图?例如,如果我们想在这个例子的标题中加入乳胶符号:

from traits.api import HasTraits, Instance
from traitsui.api import View, Item
from chaco.api import Plot, ArrayPlotData
from enable.component_editor import ComponentEditor
from numpy import linspace, sin

class LinePlot(HasTraits):
    plot = Instance(Plot)
    traits_view = View(
        Item('plot',editor=ComponentEditor(), show_label=False),
        width=500, height=500, resizable=True, title="Chaco Plot")

    def __init__(self):
        super(LinePlot, self).__init__()
        x = linspace(-14, 14, 100)
        y = sin(x) * x**3
        plotdata = ArrayPlotData(x=x, y=y)
        plot = Plot(plotdata)
        plot.plot(("x", "y"), type="line", color="blue")
        plot.title = "sin(x) * x^3"
        self.plot = plot

if __name__ == "__main__":
    LinePlot().configure_traits()

我尝试将标题替换$sin(x)^3$为无济于事,并想知道这是否可能?截图如下:

在此处输入图像描述

4

1 回答 1

1

不,它不是(它是一个 matplotlib 功能)。但是您可以尝试在简单的情况下使用 unicode 符号。

于 2015-01-30T14:28:15.200 回答