0
votes

This is the link to the dataset. I have this contour plot which has a bit rough edges. My question is, how can I smooth these edges these edges correspond to Nan. I filled in the Z matrix with Nan so as to remove unwanted values.

I also wanted to ask that why shading flat and interp is not working on this contour.

I have set shading to flat and in Matlab2013b I get proper flat figure but in Matlab 2014b and 2015b I am getting this figure.

MATLAB 2015b:

enter image description here

MATLAB 2013b enter image description here

How can I obtain perfectly meshed plot in Matlab 2015b, I checked for shading options in the documentation and there are only 3 faceted, interp and flat.

shading flat works in 2013b but not in subsequent versions. Can someone tell me why is it so?

This is the sample code which I am using right now:

clear all; close all; clc;

load temperature.txt;

time = temperature(:,1);               % This column contains the time
x = temperature(:,2);                  % This column contains the x values.
temperature_system = temperature(:,3); % This column contains the temperatures.

% Rejecting the outliers
pos = (temperature_system > prctile(temperature_system,97));
time(pos) = [];
x(pos) = [];
temperature_system(pos) = [];

X1 = [time x];


F = scatteredInterpolant(X1,temperature_system);
x1 = linspace(min(x),max(x),100);
x2 = linspace(min(time),max(time),100);
[X,Y] = meshgrid(x2,x1);
Z = F(X,Y);

% Is the data below the criteria for all points in space at a specific time
emptyTime = all(Z<10,1);
emptySpace = all(Z<10,2);
[emptyTime, emptySpace] = meshgrid(emptyTime, emptySpace);
Z(emptyTime | emptySpace) = nan;

% Replacing the remaining zeros with nan
pos = find(Z<1);
Z(pos) = nan;
f1 = figure(1);
%set(f1,'renderer','zbuffer');

%surf(X,Y,Z);

[C,h] = contourf(X,Y,Z, 'Linestyle', 'none');
shading flat;
colormap(jet);
q = colorbar;
set(q,'direction','reverse');
q.Label.String = 'Temperature';


xlabel('Time (ps)','FontSize', 16, 'FontWeight', 'bold',...
   'FontName', 'Helvetica', 'Color', 'Black');
ylabel('Length of box (A)','FontSize', 16, 'FontWeight', 'bold',...
    'FontName', 'Helvetica', 'Color', 'Black');

set(gca,'LineWidth',3,'TickLength',[0.02 0.02]);
set(gca,'XMinorTick','on');
set(gca,'YMinorTick','on','XTicksBetween', 5);
set(gca,'FontSize',12,'FontName','Helvetica');
1
I'm not sure I exactly understand what you're pointing out as the difference between the two. The only thing that I see is simply the edges between the difference contours. One big difference between 2014b+ and 2014a is the default figure renderer. In hg2, it's 'opengl', and in older versions it's 'painters'. Maybe play with that if you're seeing differences in the rendering for the same plot?Suever
Yes you've got it right I am trying to remove the edged between the different contours. And I change my script to use the default renderer but it is still the same earlier I was using buffer. Any suggestions?Ankit Mishra
It's the third question you ask about this contour plot, without giving any sample data. You should really read How to create a Minimal, Complete, and Verifiable example and try to make your question respect that. You will get much quicker and better answers.Hoki

1 Answers

1
votes

It's difficult to test the issue without having your data. I got rid of the lines by means of the LineStyle property:

enter image description here

Code:

Z = peaks(20);
subplot(2,1,1);
contourf(Z,10);
colorbar;
subplot(2,1,2);
contourf(Z,10, 'LineStyle', 'none');
colorbar;