Plot inverse colors in Matlab?

colors, inverse, matlab, plot

Solution

I believe it's not possible to automatically invert color of the plot based on background image. You probably can rasterize the plot and somehow combine it with the image (xor?).

Here is another solution. If you can use closed markers, like circle, square, triangle, you can set different MarkerEdgeColor and MarkerFaceColor, so the marker will be visible against different colors.

h = plot(1:5,'o');
set(h,'MarkerEdgeColor','b')
set(h,'MarkerFaceColor','r')

Problem

I'm plotting on top of an image in Matlab. Sometimes, I can't see what's being plotted because the color of the image underneath is too close to the color of the image at the same location. I could just always change the color of the plot (e.g. from 'rx' to 'bx'), but that's cumbersome. Is it possible to plot the inverse color of what's underneath so that the overlay is always visible?

Original source