Change format of field contour labels that have been manually added in a tiled layout
Hi,
Trying to manually add contour labels over a filled contour plot over a narrow range of values.
Matlab returns the error:
Error using hgconvertunits
The reference object is invalid.
Any ideas how I can manually add labels to a tiledlayout?
I also assume there is no workaround for avoiding the contours from striking through the labels when added manually?
Thank you
a = 0.98;
b = 1.02;
Z = round(((b-a).*rand(99,99) + a),2);
XY = [-0.375:.125:.375];
no_levels = 8;
npoints = [99 99]; % define improved resolution
Xfine = linspace(XY(1),XY(end),npoints(1)); % y coords
Yfine = linspace(XY(1),XY(end),npoints(2)); % z coords
[Xfine Yfine] = meshgrid(Xfine,Yfine); % create mesh
tiledlayout(1,2)
for i = 1:2
nexttile(1)
[C,H] = contourf(Xfine,Yfine,Z,no_levels,’-‘);
% clabel(C,H,’interpreter’,’latex’,’FontSize’,14);
% H.LevelList = round(H.LevelList,1); % rounds levels to 1st decimal place
clabel(C,H,"manual",’FontSize’, 22)
hold on
ylim([-0.5 0.5]);
y = ylim;
yticks([y(1):.25:y(2)])
xticks([-.5:.25:.5])
xlim([-.55 .55])
axis square
endHi,
Trying to manually add contour labels over a filled contour plot over a narrow range of values.
Matlab returns the error:
Error using hgconvertunits
The reference object is invalid.
Any ideas how I can manually add labels to a tiledlayout?
I also assume there is no workaround for avoiding the contours from striking through the labels when added manually?
Thank you
a = 0.98;
b = 1.02;
Z = round(((b-a).*rand(99,99) + a),2);
XY = [-0.375:.125:.375];
no_levels = 8;
npoints = [99 99]; % define improved resolution
Xfine = linspace(XY(1),XY(end),npoints(1)); % y coords
Yfine = linspace(XY(1),XY(end),npoints(2)); % z coords
[Xfine Yfine] = meshgrid(Xfine,Yfine); % create mesh
tiledlayout(1,2)
for i = 1:2
nexttile(1)
[C,H] = contourf(Xfine,Yfine,Z,no_levels,’-‘);
% clabel(C,H,’interpreter’,’latex’,’FontSize’,14);
% H.LevelList = round(H.LevelList,1); % rounds levels to 1st decimal place
clabel(C,H,"manual",’FontSize’, 22)
hold on
ylim([-0.5 0.5]);
y = ylim;
yticks([y(1):.25:y(2)])
xticks([-.5:.25:.5])
xlim([-.55 .55])
axis square
end Hi,
Trying to manually add contour labels over a filled contour plot over a narrow range of values.
Matlab returns the error:
Error using hgconvertunits
The reference object is invalid.
Any ideas how I can manually add labels to a tiledlayout?
I also assume there is no workaround for avoiding the contours from striking through the labels when added manually?
Thank you
a = 0.98;
b = 1.02;
Z = round(((b-a).*rand(99,99) + a),2);
XY = [-0.375:.125:.375];
no_levels = 8;
npoints = [99 99]; % define improved resolution
Xfine = linspace(XY(1),XY(end),npoints(1)); % y coords
Yfine = linspace(XY(1),XY(end),npoints(2)); % z coords
[Xfine Yfine] = meshgrid(Xfine,Yfine); % create mesh
tiledlayout(1,2)
for i = 1:2
nexttile(1)
[C,H] = contourf(Xfine,Yfine,Z,no_levels,’-‘);
% clabel(C,H,’interpreter’,’latex’,’FontSize’,14);
% H.LevelList = round(H.LevelList,1); % rounds levels to 1st decimal place
clabel(C,H,"manual",’FontSize’, 22)
hold on
ylim([-0.5 0.5]);
y = ylim;
yticks([y(1):.25:y(2)])
xticks([-.5:.25:.5])
xlim([-.55 .55])
axis square
end contour labels, tiledlayout MATLAB Answers — New Questions