enthought / chaco

Chaco is a Python package for building interactive and custom 2-D plots.
http://docs.enthought.com/chaco/
Other
292 stars 99 forks source link

Y label gets clipped #564

Closed rahulporuri closed 3 years ago

rahulporuri commented 3 years ago

Problem Description

The Y label in the following example doesn't get displayed while the X label gets displayed.

why-chaco-why

Reproduction Steps:

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

Expected behavior:

We expect the Y label to be displayed.

OS, Python version: Windows 10 Pro. Python 3.6.0. Chaco 4.8.0. Enable 4.8.1.

Originally reported on the ETS Users Google Group - https://groups.google.com/g/ets-users/c/gHQmFsVMVhw

timdiller commented 3 years ago

Note that the title is actually there, but the default padding is such that most of the text is clipped. This requires overriding the plot.padding_left attribute to create enough space to show the text.

corranwebster commented 3 years ago

This is not a bug per-se as @timdiller points out - but what might help with these problems is to perhaps adjust the default values of the right and left padding based on the presence or absence of a non-empty axis title.

Or alternatively, use the edge of the padding as the guide for the location of the axis title?