You have found a bug, and I have not yet tracked down the cause and solution. In the meantime, a workaround (or superior alternative--see below) is to use set_data(x, y) instead of set_xdata and set_ydata. See the attached modification of your demo, which also shows an alternative way of making the mask.
Every time when I pass a masked array to set_xdata() I get an error
"MA.MA.MAError: Mask and data are not compatible".
See http://www-users.rwth-aachen.de/torsten.bronger/hall.py for the
code that provokes this error. The "plot" command works: It
produces a plot with the desired gap (realised by the masked array).
However, the first line.set_xdata(x_values) fails, although I even
didn't change the x_values.
set_xdata and set_ydata call set_data, so it is actually more efficient to call set_data in the first place. (This seems odd; one might expect the opposite, with set_data calling set_xdata and set_ydata.)
hall1.py (984 Bytes)