I have got a table from which I'd like to plot two fields ('Analysis' against 'Date'). The 'Analysis' field is a table itself, and I am plotting a particular field from it (PMkW_corr_298_RPMcorr). The health_monitor_log table has a field, 'Unit', from which I'd like to include unique values of in the legend. Each unique Unit has a different marker and/or colour.
I have tried the code below, but it doesn't seem to exclude repeat values of Unit from the legend. So for my first unique Unit entry, I'm expecting a triangle marker in the legend, and for the second unique Unit, a diamond. But when I type two entries for the legend in, I get two triangles, which is because the first two entries in the table have the triangle markers.
[c,ia,ic]=unique(health_monitor_log.Unit); marker={'^','d','<','>','s','p','h'}; colour={'k','r','y','g','b','c','m'}; for i=1:size(health_monitor_log,1) hold on if any(strcmp('etath_PM_kW',fieldnames(health_monitor_log.Analysis{i,1}))) p=plot(health_monitor_log.Date(i),health_monitor_log.Analysis{i}.PMkW_corr_298_RPMcorr,'Marker',char(marker(health_monitor_log.Marker(i))),'MarkerFaceColor',char(colour(health_monitor_log.Colour(i))),'MarkerEdgeColor',[1,1,1]) if ~ismember(i,ia) ant=get(p,'Annotation'); if iscell(ant) for j=1:length(ant) set(get(ant{j},'LegendInformation'),'IconDisplayStyle','off') end else set(get(ant,'LegendInformation'),'IconDisplayStyle','off') end end end end
Best Answer