kakearney / contourfcmap-pkg

Create a filled contour plot in Matlab, with better color-to-value clarity
MIT License
17 stars 2 forks source link

The 'recolor' options fails when x values are datenumbers #1

Closed kakearney closed 9 years ago

kakearney commented 9 years ago

This bug was pointed out to me by Kellen on the MatlabCentral Answers forum.

In 2014b, it appears that the TriangleStrip coordinates (h.FacePrims.VertexData.StripData) don't correspond to axis coordinates when datenumbers are used, causing the recolor method to fail on line 364.

An example:

z = peaks(100);
t = datenum(2000,1,1) + (1:100);
y = 1:100;
clev = [-5 -3 -2:.5:2 3 5];
cmap = jet(12);
hc = contourfcmap(t,y,z,clev,cmap, 'method', 'recolor');

Result:

Subscript indices must either be real positive integers or logicals.

Error in contourfcmap (line 364)
            newcol = cdata(idx,:);
kakearney commented 9 years ago

Fixed, I think. I'm still not sure what the threshold of axis limits is that causes TriangleStrip VertexData to switch from axis coordinates to normalized coordinates, but the function now checks for this ahead of time.