【发布时间】:2016-06-04 15:33:19
【问题描述】:
This is the link to the dataset. 我有这个轮廓图,它的边缘有点粗糙。我的问题是,我怎样才能平滑这些边缘,这些边缘对应于 Nan。我用 Nan 填充了 Z 矩阵,以便删除不需要的值。
我还想问为什么 shading flat 和 interp 在这个轮廓上不起作用。
我已将阴影设置为平面,在 Matlab2013b 中我得到了正确的平面图,但在 Matlab 2014b 和 2015b 中我得到了这个图。
MATLAB 2015b:
如何在 Matlab 2015b 中获得完美网格图,我检查了文档中的着色选项,只有 3 个刻面、interp 和 flat。
shading flat 在 2013b 中有效,但在后续版本中无效。谁能告诉我为什么会这样?
这是我现在使用的示例代码:
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');
【问题讨论】:
-
我不确定我是否完全理解您所指出的两者之间的区别。我唯一看到的只是差异轮廓之间的边缘。 2014b+ 和 2014a 之间的一大区别是默认的图形渲染器。在 hg2 中,它是“opengl”,而在旧版本中,它是“painters”。如果您发现同一情节的渲染存在差异,也许可以尝试一下?
-
是的,你做对了,我正在尝试去除不同轮廓之间的边缘。我更改了我的脚本以使用默认渲染器,但它仍然与我之前使用缓冲区相同。有什么建议吗?
-
这是你问的关于这个等高线图的第三个问题,没有给出任何样本数据。您真的应该阅读How to create a Minimal, Complete, and Verifiable example 并尝试让您的问题尊重这一点。您将获得更快更好的答案。
标签: matlab