When plotting (type="bar") data with NaN, the plot goes blank and a traceback is emitted at paint-time.
Reproduction Steps:
import numpy
from enable.api import ComponentEditor
from traits.api import *
from traitsui.api import *
from chaco.api import *
from chaco.tools.api import *
class PlotExample(HasTraits):
plot = Instance(Plot)
def _plot_default(self):
index = numpy.arange(10.)
series = index * 10
series[-1] = float("nan")
plot_data = ArrayPlotData(index=index)
plot_data.set_data("series", series)
plot = Plot(plot_data)
plot.plot(("index", "series"), type="bar", bar_width=0.8)
# optional: NaN is initially out of the visible range, so it only crashes upon panning
plot.index_range.low_setting = -0.5
plot.index_range.high_setting = 6.5
plot.tools.append(PanTool(plot, constrain=True, constrain_direction="x"))
return plot
traits_view = View(
UItem("plot", editor=ComponentEditor()),
width=400, height=400, resizable=True,
)
demo = PlotExample()
demo.configure_traits()
Expected behavior:
(For instance) Emit a warning when NaNs are encountered in bar plot data, possibly not at paint-time but as soon as the plot data is updated with offending values. Then avoid plotting the corresponding bar.
OS, Python version: [Enter OS name and Python version]
Problem Description
When plotting (
type="bar"
) data with NaN, the plot goes blank and a traceback is emitted at paint-time.Reproduction Steps:
Expected behavior:
(For instance) Emit a warning when NaNs are encountered in bar plot data, possibly not at paint-time but as soon as the plot data is updated with offending values. Then avoid plotting the corresponding bar.
OS, Python version: [Enter OS name and Python version]
Python 3.8, OS irrelevant, backend
agg
.