Clear Filters
Clear Filters

How to avoid patch color in legend?

3 views (last 30 days)
Luca Re
Luca Re on 3 May 2024
Edited: Voss on 3 May 2024
Sorry , i can to send only you a little piece of code..
here "
plot(Ax_Eq,XDates(xx_:end),TE_strum(xx_:end,i)','Color',"black",'LineWidth',width_arr(i));
(SECOND PLOT)
i plot with another color the the last part of equity
Problem is the legend:
Some are colored black in the legend.. Instead I only want the legend like those of the initial plot (FIRST PLOT)
("
plot(Ax_Eq,XDates,TE_strum(:,i)','DisplayName',STR_name{i},'Color',col(i,:),'LineWidth',width_arr(i));
")
for i=1:c
if STR_type(i)==1 %%se sono aggregate
SumCTR_color(b(i),:)= col(i,:); %%cosi nel draw del SumCTR_strum gli do il colore uguale
end
%%********* FIRST PLOT ***********************
plot(Ax_Eq,XDates,TE_strum(:,i)','DisplayName',STR_name{i},'Color',col(i,:),'LineWidth',width_arr(i));
%%**********************************************
text(Ax_Eq,r-2,TE_strum(end,i),strcat({' '},num2str(i)),'Color',col(i,:),'Interpreter','none');
if app.OOScolorCheckBox.Value %%mi colora di nero da dove inizia solo l'OOS (se ci sono 4 sistemi prende l'OOS piu' recente!!)!
oos=datetime(string({app.Sis.OOS}),'Format','dd/MM/yyyy');
xx=cell2mat(app.Seraf_T(:,3));
[~,xx_]=find(max(oos(xx))==XDates); %%max perche prendo l'OOS piu' recente!
%%********* SECOND PLOT ***********************
plot(Ax_Eq,XDates(xx_:end),TE_strum(xx_:end,i)','Color',"black",'LineWidth',width_arr(i));
%%***************************************
end
%%******************************
end
%%*************************
nm=Convert_ArrayDouble_StringDollar_Struct(TE_strum(end,:)',0);
tm=compose("%s", Ntrad_strum');
leg=strcat(string(1:c)',{' - '},string(STR_name),"==>",nm," ",tm);
legend(Ax_Eq,leg,'Location','northwest','Interpreter','none','Box','off');

Accepted Answer

Voss
Voss on 3 May 2024
Edited: Voss on 3 May 2024
In the call to legend, you can specify which lines (or whatever) you want included.
Here it's legend_lines:
legend_lines = gobjects(1,c);
for i=1:c
if STR_type(i)==1 %%se sono aggregate
SumCTR_color(b(i),:)= col(i,:); %%cosi nel draw del SumCTR_strum gli do il colore uguale
end
%%********* FIRST PLOT ***********************
legend_lines(i) = plot(Ax_Eq,XDates,TE_strum(:,i)','DisplayName',STR_name{i},'Color',col(i,:),'LineWidth',width_arr(i));
%%**********************************************
text(Ax_Eq,r-2,TE_strum(end,i),strcat({' '},num2str(i)),'Color',col(i,:),'Interpreter','none');
if app.OOScolorCheckBox.Value %%mi colora di nero da dove inizia solo l'OOS (se ci sono 4 sistemi prende l'OOS piu' recente!!)!
oos=datetime(string({app.Sis.OOS}),'Format','dd/MM/yyyy');
xx=cell2mat(app.Seraf_T(:,3));
[~,xx_]=find(max(oos(xx))==XDates); %%max perche prendo l'OOS piu' recente!
%%********* SECOND PLOT ***********************
plot(Ax_Eq,XDates(xx_:end),TE_strum(xx_:end,i)','Color',"black",'LineWidth',width_arr(i));
%%***************************************
end
%%******************************
end
%%*************************
nm=Convert_ArrayDouble_StringDollar_Struct(TE_strum(end,:)',0);
tm=compose("%s", Ntrad_strum');
leg=strcat(string(1:c)',{' - '},string(STR_name),"==>",nm," ",tm);
legend(Ax_Eq,legend_lines,leg,'Location','northwest','Interpreter','none','Box','off');

More Answers (0)

Community Treasure Hunt

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

Start Hunting!