Is there an equivalent to CLEGENDM for contour plots in MATLAB (R2013a)?

조회 수: 44 (최근 30일)
How can I add a legend to my contour plot? Why is CLEGENDM only available as part of the Mapping Toolbox? This function would save lots of time when creating a legend for a contour plot, and having a similar feature in base MATLAB is something most users would like to see.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2013년 10월 25일
There is no equivalent to CLENGENDM in base MATLAB. Here is an example that shows how you can add a legend to a contour plot:
clc
clear all
close all
x = -3:0.125:3;
y = -3:0.125:3;
[X,Y] = meshgrid(x,y);
Z = peaks(X,Y);
v = -2 : 1 : 2;
figure
contour(X,Y,Z,v);
leg = arrayfun(@num2str,v,'UniformOutput',false);
hc = get(gca,'children');
c = {leg};
legend(get(hc,'Children'),'String',c{:})

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

제품


릴리스

R2013a

Community Treasure Hunt

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

Start Hunting!

Translated by