是否可以让 chaco plot 自动显示完整输出而不隐藏刻度和标签的部分?例如,这是标准示例的输出:
from chaco.api import ArrayPlotData, Plot
from enable.component_editor import ComponentEditor
from traits.api import HasTraits, Instance
from traitsui.api import View, Item
class MyPlot(HasTraits):
plot = Instance(Plot)
traits_view = View(Item('plot', editor = ComponentEditor(), show_label = False),
width = 500, height = 500, resizable = True)
def __init__(self, x, y, *args, **kw):
super(MyPlot, self).__init__(*args, **kw)
plotdata = ArrayPlotData(x=x,y=y)
plot = Plot(plotdata)
plot.plot(("x","y"), type = "line", color = "blue")
self.plot = plot
import numpy as np
x = np.linspace(-300,300,10000)
y = np.sin(x)*x**3
lineplot = MyPlot(x,y)
lineplot.configure_traits()
如您所见,刻度标签的部分被隐藏了。我唯一能做的就是手动调整绘图的左填充。但是,当您在应用程序中使用绘图绘制不同的数据和不同的比例或字体时,这变得非常不合时宜。是否有可能以某种方式自动调整填充以包含所有相关信息?
UPD .:我找到了轴的 ensure_labels_bounded 属性,但似乎没有效果。