How to add a black line using brewermap

4 ビュー (過去 30 日間)
A_V_G
A_V_G 2019 年 11 月 25 日
コメント済み: A_V_G 2019 年 11 月 26 日
Hi,
I want to add an extra black line to a plot with 5 lines where I am using:
map = brewermap(5,'Blues');
set(0, 'DefaultAxesColorOrder', map)
legendLabels=[];
for iA=1:length(Avec)
plot(xvec,yvec, '*-', 'LineWidth',3,'Markersize',3); hold all
legendLabels=[legendLabels,{['$A=' num2str(Avec(iA)) '$']}];
end
plot(Avec, minvec,':k','LineWidth',3,'Markersize',3); hold all % black line
lh=legend(legendLabels{:},'min','fontweight', 'bold','fontsize',24,'Interpreter', 'latex','Location','best','NumColumns',1);
Right now in the legend I see the data twice, and the same colours again, no black line.
Thanks in advance for your help!
  2 件のコメント
Stephen23
Stephen23 2019 年 11 月 25 日
@A_V_G: please show/upload the code you are using, together with sample data.
A_V_G
A_V_G 2019 年 11 月 25 日
Updated the text

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2019 年 11 月 25 日
What is that thing? A legend? How did you make it? Why are there no text strings with it? Did you specify null strings?
If you want another legend line, with no curve with it, you can just plot a single point in the color you want.
plot(x1(1), y1(1), 'k.');
then call legend. Because of that extra call to plot, you should have another legend line, though since the plot is just a single point, you won't notice it.
To put up a line you can call line([x1,x2], [y1,y2]).
Call line with the y values being the min value you want the line at:
hold on;
line(xlim, [minValue, minValue], 'Color', 'k', 'LineWidth', 2);
  3 件のコメント
Image Analyst
Image Analyst 2019 年 11 月 26 日
編集済み: Image Analyst 2019 年 11 月 26 日
No, because I get
Undefined function or variable 'brewermap'.
You forgot to included the products when you filled out the form to submit your question. Evidently brewermap is either one of your functions you forgot to attach, or in a toolbox that I don't have. Please spare the others the trouble I had by listing in the product section what toolbox it's in, or else attach it, if it's a custom function of yours.
Create your legendLabels like this, not like what you did:
legendLabels{iA} = ['$A=', num2str(Avec(iA)), '$'];
Any idea why your legends all say "data n" instead of "$A=n"???
A_V_G
A_V_G 2019 年 11 月 26 日
Solved, thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by