Enhancing the plot quality in matlab

22 views (last 30 days)
Ankit Mishra
Ankit Mishra on 24 Feb 2016
Edited: Mike Garrity on 24 Feb 2016
I have this Dataset and I have obtained the contour plot of this dataset using the below mentioned script.
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.
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;
pos = find(Z<1);
Z(pos) = nan;
f1 = figure(1);
[C,h] = contourf(X,Y,Z, 'Linestyle', 'none');
set(f1,'renderer','opengl');
colormap(jet);
q = colorbar;
q.Label.String = 'Temperature(K)';
qpos = q.Position;
qpos(1) = 1.0*qpos(1);
q.Position = qpos;
map = colormap;
% cmap(1,:) = [1,1,1];
% colormap(cmap);
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,'YLim',[0 1400]);
set(gca,'YTick',[0:200:1400]);
set(gca,'LineWidth',3,'TickLength',[0.02 0.02]);
set(gca,'XMinorTick','on');
set(gca,'YMinorTick','on');
set(gca,'FontSize',12,'FontName','Helvetica');
So, my questions are the following:
1. How can I make the picture quality look really good.
2. How can I remove the uneven edged on the top and bottom is there a way to filter these out. These are created due to substitution of the Z value with nan.
3. I have looked for some of the filters like gaussian and laplacians but I am not sure how to use them because they are used on an existing image and modify the rub values. But I have this plot, so how can I enhance its quality to make it look publication quality.
P.S.: Any suggestions to these questions will be greatly appreciated, please do comment in the comment section if you have any problem in accessing the dataset. Its a bit large dataset around 40 MB.
I will be thankful to you for your suggestions as I am stuck on trying to enhance this image from 2 days now and could not come up with anything. So I need help from you all.
  1 Comment
Mike Garrity
Mike Garrity on 24 Feb 2016
It's always good to take a close look at your original data. If you zoom in and compare your scatter data to your gridded data:
surf(X,Y,Z)
hold on
scatter3(time,x,temperature_system,'.','MarkerEdgeColor','black')
xlim([5 10])
ylim([800 1000])
xlabel('time')
ylabel('x')
zlabel('temperature_system','Interpreter','none')
You can see that you're nowhere near the resolution require to capture what's going on along your time axis. If you are going to decimate that far, you're going to need to be very careful about low-pass filtering. Just using scatteredInterpolant isn't going to properly deal with all of the higher frequencies you're discarding.
Going to 500x300 gives me this:
That's better, at least along that sharp gradient on the left. It's still not great along the bottom. As I explained in this blog post, the contour functions can be a bit tricky with the 'nan trick'. We probably need to be a bit more careful.
I would be a bit concerned about the way you're deciding where to insert the nans. You're performing the extrapolation with the scatteredInterpolant, and then thresholding using those values. That means that in some areas you might be catching the first couple of values of the extrapolation. I would suggest using the bounds of the input points to clip the grid.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!