kakearney / contourfcmap-pkg

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

Example fail with error #2

Closed ssimm008 closed 9 years ago

ssimm008 commented 9 years ago

With my R2014b, running your example The option : 'method', 'calccontour', gives the following error

Undefined function or variable "nnan".

Error in contourfcmap (line 495) [xn, yn] = polyjoin(xc(end-nnan-1:end), yc(end-nnan-1:end));

kakearney commented 9 years ago

Thanks for letting me know; guess I didn't test things quite thoroughly enough when I added support for data with NaNs a few weeks ago. A fixed version should be uploaded by tomorrow.

-Kelly

On Fri, Feb 27, 2015 at 3:11 PM, ssimm008 notifications@github.com wrote:

With my R2014b, running your example The option : 'method', 'calccontour', gives the following error

Undefined function or variable "nnan".

Error in contourfcmap (line 495) [xn, yn] = polyjoin(xc(end-nnan-1:end), yc(end-nnan-1:end));

— Reply to this email directly or view it on GitHub https://github.com/kakearney/contourfcmap-pkg/issues/2.

ssimm008 commented 9 years ago

Another quick thing on your example

v = version;

On Sat, Feb 28, 2015 at 4:57 PM, Kelly Kearney notifications@github.com wrote:

Thanks for letting me know; guess I didn't test things quite thoroughly enough when I added support for data with NaNs a few weeks ago. A fixed version should be uploaded by tomorrow.

-Kelly

On Fri, Feb 27, 2015 at 3:11 PM, ssimm008 notifications@github.com wrote:

With my R2014b, running your example The option : 'method', 'calccontour', gives the following error

Undefined function or variable "nnan".

Error in contourfcmap (line 495) [xn, yn] = polyjoin(xc(end-nnan-1:end), yc(end-nnan-1:end));

— Reply to this email directly or view it on GitHub https://github.com/kakearney/contourfcmap-pkg/issues/2.

— Reply to this email directly or view it on GitHub https://github.com/kakearney/contourfcmap-pkg/issues/2#issuecomment-76549153 .

kakearney commented 9 years ago

Yup, left that one out of the example. Fixed now. Thanks!

On Sat, Feb 28, 2015 at 7:33 PM, ssimm008 notifications@github.com wrote:

Another quick thing on your example

v = version;

On Sat, Feb 28, 2015 at 4:57 PM, Kelly Kearney notifications@github.com wrote:

Thanks for letting me know; guess I didn't test things quite thoroughly enough when I added support for data with NaNs a few weeks ago. A fixed version should be uploaded by tomorrow.

-Kelly

On Fri, Feb 27, 2015 at 3:11 PM, ssimm008 notifications@github.com wrote:

With my R2014b, running your example The option : 'method', 'calccontour', gives the following error

Undefined function or variable "nnan".

Error in contourfcmap (line 495) [xn, yn] = polyjoin(xc(end-nnan-1:end), yc(end-nnan-1:end));

— Reply to this email directly or view it on GitHub https://github.com/kakearney/contourfcmap-pkg/issues/2.

— Reply to this email directly or view it on GitHub < https://github.com/kakearney/contourfcmap-pkg/issues/2#issuecomment-76549153

.

— Reply to this email directly or view it on GitHub https://github.com/kakearney/contourfcmap-pkg/issues/2#issuecomment-76562884 .

kakearney commented 9 years ago

It looks correct to me. Did you mean to plot different data in the two figures? The first is showing Z, while the second plots R. Note that if you meant to plot R in the contour plot, you might need to increase the resolution of X and Y to get the intended circular contours along the outer portions.

On Sun, Mar 1, 2015 at 8:28 AM, ssimm008 notifications@github.com wrote:

Thanks for the quick fix

I guess I'm doing something wrong Does this behavior look correct

[X,Y] = meshgrid(-8:.5:8); R = sqrt(X.^2 + Y.^2) + eps;

Z = 40*sin(R)./R; figure imagesc(Z,[0 20]) colormap(jet)

clev = 0:20; figure cm = jet(length(clev)-1); hc = contourfcmap(X,Y,R,clev,cm, ... 'lo',[0 0 0],... 'hi',[.9 .9 .9],... 'method','calccontour',... 'cbarloc','eastoutside');

— Reply to this email directly or view it on GitHub https://github.com/kakearney/contourfcmap-pkg/issues/2#issuecomment-76598998 .

ssimm008 commented 9 years ago

Sorry poor example; I was trying some of my own debugging. How about this example?

(My first attempt at dropbox...hope it works) https://www.dropbox.com/s/dt4vqwclxz8cfw2/Figure2a_NumericalExampleConstant.fig?dl=0

fileName = 'Figure2a_NumericalExampleConstant.fig'; uiopen(fileName,1) colorbar off

ih = findobj('type','image'); x = get(ih,'XData'); y = get(ih,'YData'); [x,y] = meshgrid(x,y); z = get(ih,'CData'); clev = [0 1:0.5:5 6:11]; figure cm = jet(length(clev)-1); cm(1,:) = [0.2 0.2 0.2]; hc = contourfcmap(x,y,z,clev,cm, ... 'lo',[0 0 0],... 'hi',[.9 .9 .9],... 'method','calccontour',... 'cbarloc','eastoutside');

Oddly enough, if I set nnan = 9; (ln 438), the result looks correct.

Sorry for all the trouble, I really like your tool. It provides more insight to the data.

Thanks Shaun

On Sun, Mar 1, 2015 at 10:00 AM, Kelly Kearney notifications@github.com wrote:

It looks correct to me. Did you mean to plot different data in the two figures? The first is showing Z, while the second plots R. Note that if you meant to plot R in the contour plot, you might need to increase the resolution of X and Y to get the intended circular contours along the outer portions.

On Sun, Mar 1, 2015 at 8:28 AM, ssimm008 notifications@github.com wrote:

Thanks for the quick fix

I guess I'm doing something wrong Does this behavior look correct

[X,Y] = meshgrid(-8:.5:8); R = sqrt(X.^2 + Y.^2) + eps;

Z = 40*sin(R)./R; figure imagesc(Z,[0 20]) colormap(jet)

clev = 0:20; figure cm = jet(length(clev)-1); hc = contourfcmap(X,Y,R,clev,cm, ... 'lo',[0 0 0],... 'hi',[.9 .9 .9],... 'method','calccontour',... 'cbarloc','eastoutside');

— Reply to this email directly or view it on GitHub < https://github.com/kakearney/contourfcmap-pkg/issues/2#issuecomment-76598998

.

— Reply to this email directly or view it on GitHub https://github.com/kakearney/contourfcmap-pkg/issues/2#issuecomment-76600368 .

kakearney commented 9 years ago

Well, I can confirm that there's something wonky going on in that example. The recolor method is going a bit crazy with this one too, so I obviously broke something when I added in NaN support. I'll have to look into it a bit more closely, but I don't think I'll have the time for that for another week or so. For now, marking as a somewhat vague bug.

ssimm008 commented 9 years ago

I'm not sure why, but...

Comment lines 496-499 seems to work...I think % [xn, yn] = polyjoin(xc(end-nnan-1:end), yc(end-nnan-1:end)); % for ii = 1:(length(S)-nnan) % [xc{ii}, yc{ii}] = polybool('-', xc{ii}, yc{ii}, xn, yn); % end

kakearney commented 9 years ago

In theory, those lines are supposed to take the original set of contour polygons (which extend through NaN-regions, if they exist) and clip away the NaN portion. If there are no NaNs in the data, I thought the xn/yn data should be empty, and therefore it should have no effect (I'm on the road without Matlab at the moment, so I can't look to see what's actually going on). Commenting it out should be a fine fix for plotting data without any NaNs in it; I'll have to run it past some other test datasets to get a robust solution for all input.

On Mon, Mar 2, 2015 at 8:39 AM, ssimm008 notifications@github.com wrote:

I'm not sure why, but...

Comment lines 496-499 seems to work...I think % [xn, yn] = polyjoin(xc(end-nnan-1:end), yc(end-nnan-1:end)); % for ii = 1:(length(S)-nnan) % [xc{ii}, yc{ii}] = polybool('-', xc{ii}, yc{ii}, xn, yn); % end

— Reply to this email directly or view it on GitHub https://github.com/kakearney/contourfcmap-pkg/issues/2#issuecomment-76733972 .

kakearney commented 9 years ago

I believe I've now fixed this issue.