Display Y Title issue

13 views
Skip to first unread message

christophe

unread,
Feb 10, 2021, 9:55:19 AM2/10/21
to Enthought Tool Suite users
Hi,
I ve changed a standard example to display X and Y title.
I see the X but not the Y.

What goes wrong ?

W7 Pro
Python 3.6
Chaco 4.8

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

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 _plot_default(self):
        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"
       
        plot.x_axis.title = "X AXIS"
        plot.y_axis.title = "Y AXIS"
       
        return plot

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


Chaco Plot.jpg

Sai Rahul Poruri

unread,
Feb 10, 2021, 10:22:34 AM2/10/21
to christophe, Enthought Tool Suite users
Hey Christophe,

Thanks for reporting this buggy behavior.

This looks like a bug in chaco. I was able to reproduce the bug on Windows 10 Pro. I opened a ticket - https://github.com/enthought/chaco/issues/564 - to track this issue on the chaco GitHub repository. 

Cheers,
Rahul.

Tim Diller

unread,
Feb 10, 2021, 10:33:31 AM2/10/21
to Enthought Tool Suite users, christophe
Christophe,
I'd like to add to Rahul's comment.  The Title is there, but it's off the left side of the screen.  I ran the code on a MacBook and saw just a tiny bit of the title showing.


The short-term fix is to adjust plot.padding_left to create more space. On my system, setting the padding to 80 worked.

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

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 _plot_default(self):
        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"

        plot.x_axis.title = "X AXIS"
        plot.y_axis.title = "Y AXIS"
        plot.padding_left = 80


        return plot

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


Hope this helps.
-Tim

_______________

Tim Diller, PhD
ティム ディラ、博士
Director, Digital Transformation Services | Enthought

--
You received this message because you are subscribed to the Google Groups "Enthought Tool Suite users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ets-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ets-users/a66ccb09-89c3-4fcd-9d38-1a5a1ef28abdn%40googlegroups.com.
<Chaco Plot.jpg>

christophe chappet

unread,
Feb 10, 2021, 10:41:29 AM2/10/21
to Tim Diller, Enthought Tool Suite users
Thanks for the padding trick, it also works on my W7 system with 80.
Cheers,
Christophe
Reply all
Reply to author
Forward
0 new messages