1

Is it possible to create a chaco plot with latex text? For example, if we wanted latex symbols in the title of this exampe:

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()

I tried replacing title with $sin(x)^3$ to no avail, and wondered if this was possible? Screenshot below:

enter image description here

Adam Hughes
  • 14,601
  • 12
  • 83
  • 122

1 Answers1

1

No, it is not (it is a matplotlib feature). But you could try to use unicode symbols for easy cases.

tillsten
  • 14,491
  • 5
  • 32
  • 41