From: Phil Kreth on 7 Apr 2010 18:30 When I use the contourf command with a specific level range, it only fills in the levels that are at or above the limits of that level. If some of the data that I am plotting with contourf has values that are below the lower limit that I specified, these levels are filled white. Is there a way that I can specifically 'find' these levels and change them from white to the color at the lower end of the colorbar? I am trying to not have any white spots with the 'jet' style colormap, and I can get the image to look proper if I change the data that is less than the lower limit of the colorbar, but then I am actually altering the data. I am hoping that there is another method of doing this through the set command. I just can't seem to find the right thing to edit. Thanks in advance, Phil
From: Walter Roberson on 7 Apr 2010 19:01 Phil Kreth wrote: > When I use the contourf command with a specific level range, it only > fills in the levels that are at or above the limits of that level. If > some of the data that I am plotting with contourf has values that are > below the lower limit that I specified, these levels are filled white. > Is there a way that I can specifically 'find' these levels and change > them from white to the color at the lower end of the colorbar? [whatever, conthandle] = contourf(Your Existing Arguments); thismap = get(gcf, 'Colormap'); fillcol = thismap(1,:); set(gca, 'Color', fillcol); cc = get(conthandle, 'Children'); for K = 1:length(cc) thiscol = get(cc(K), 'FaceColor'); if all(thiscol == 1) %all white and not string 'flat' set(cc(K), 'FaceColor', fillcol); end end
From: Phil Kreth on 8 Apr 2010 00:20 > [whatever, conthandle] = contourf(Your Existing Arguments); > > thismap = get(gcf, 'Colormap'); > fillcol = thismap(1,:); > > set(gca, 'Color', fillcol); > > cc = get(conthandle, 'Children'); > for K = 1:length(cc) > thiscol = get(cc(K), 'FaceColor'); > if all(thiscol == 1) %all white and not string 'flat' > set(cc(K), 'FaceColor', fillcol); > end > end This command: set(gca, 'Color', fillcol); actually changes the whole background of the contour plot to the color of the lowest level. While this does fill in the portion that I am interested in, the rest of the code in the for loop does not undo this. I have actually found out that the contour plot does not even recognize this data as being plotted. When I click on the datatip tool, I cannot put a datatip marker in the white region, however, when I put it close to the white region and then move the marker into the white region, it does read out the correct level. Maybe I need to actually add an entire contour for this region to the current plot? Thank you for the swift reply, Walter. Regards, Phil
From: Walter Roberson on 8 Apr 2010 00:34 Phil Kreth wrote: > This command: set(gca, 'Color', fillcol); actually changes the whole > background of the contour plot to the color of the lowest level. While > this does fill in the portion that I am interested in, the rest of the > code in the for loop does not undo this. Yup. When one of your contours that is below the cut-off happens to lie right at the very edge of the the plot box, then contourf() does not create a rectangular patch() around the plot box: it creates a patch() that zigs and zags around the cut-out area. Because that area is not part of any patch, the only way to colour it is to set the axis color. To get around that, you would have to figure out which parts of the whitespace represent the edge of the contour level just below your cut-off, and draw patches for each of those... An alternate approach would be to not use a contour level cut-off when you draw the plot, and instead chase the axis children to find those whose ZData is below the real cutoff and change their FaceColor to white, and set the FaceColor of the boundary one to the color at the bottom of the color map. Hmmm, I seem to recall that it is possible to specify the exact color for each contour in the contourf() call, so just create one extra bottom contour level and assign the bottom of the colormap to it, and give the other contours appropriate colours.
From: Phil Kreth on 8 Apr 2010 01:25 > An alternate approach would be to not use a contour level cut-off when > you draw the plot, and instead chase the axis children to find those > whose ZData is below the real cutoff and change their FaceColor to > white, and set the FaceColor of the boundary one to the color at the > bottom of the color map. Hmmm, I seem to recall that it is possible to > specify the exact color for each contour in the contourf() call, so just > create one extra bottom contour level and assign the bottom of the > colormap to it, and give the other contours appropriate colours. Actually, I just had a hit-your-forehead moment. I got the plot to show these contours by plotting the entire contourf without a specific set of levels. Then, I put a hold on and then plotted the contourf with the levels I desired. This worked fine for the plot to show the way I wanted it. I can't believe I didn't realize this at first. I was using MatLab to calculate different variables from some PIV data that I have and comparing the results with the same calculations performed in TecPlot. TecPlot automatically fills levels that are below the specified lower limit, while MatLab did not. I was specifying the levels in MatLab based on the levels in TecPlot, and suddenly had those white blotches. I do appreciate the help, but I do not think that I can easily implement your suggested solution as my mesh is not a simple x-y style mesh. At any rate, plotting two contours with a hold is a simple solution to the problem. Thanks again, Phil
|
Pages: 1 Prev: function plot in for loop Next: merge two diagonal matrix |