Stem plot with minimal spaces between lines

4 ビュー (過去 30 日間)
shane watson
shane watson 2019 年 12 月 10 日
コメント済み: Adam Danz 2019 年 12 月 14 日
Hello,
I'm using stem plot to show my data here is my code. However, my question is there are spaces between two stem lines, I wanted to fill the space with same stem lines, can someone guide me regarding this. e.g., stem plots 5 and 5 but I really need to insert some more line between these vaules to fill the space and the total array values remain 24 same. Thanks in advace.
t=[5 5 5 5 5 5 6 2 2 2 2 4 4 4 4 4 4 4 1 1 6 6 6 6];
stem(t,'-s','MarkerFaceColor',[0 1 0],'LineWidth',1.5);
hold on
  4 件のコメント
Adam Danz
Adam Danz 2019 年 12 月 11 日
Done. Let me know if there are any other loose ends.
shane watson
shane watson 2019 年 12 月 11 日
@Adam, Fantastic, you're great. The Only things that make me in trouble is now the legend problem, I have three data 1, data 2, data 3. 'data 1' is simple plot, 'data 2' is filled with color and polkadots and '3' is filled with color only. So the legend should show this way, but in my case legend show the data but in data 2 only shows symbol and in data 3 shows the color of data 2. Kindly see image it illustrates the problem.Legend.PNG

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

採用された回答

Adam Danz
Adam Danz 2019 年 12 月 11 日
"The Only things that make me in trouble is now the legend problem, I have three data 1, data 2, data 3."
Method 1: turn off IconDisplayStyle
Two steps:
1) turn off the icon display of the polkadot handle
2) call legend after you to step 1.
h = plot(inX,inY,'k.','MarkerSize',4,'MarkerFaceColor','k'); % Plot polkadots
h.Annotation.LegendInformation.IconDisplayStyle = 'off' % Turn off legend display for polkadots
legend(. . .) % Create the legend
Method 2: Specify handles in legend
Two steps:
1) get the handles to all objects you want in the legend
2) Create the legend at the end and provide those handles as input.
hold on
h1 = plot(. . ., 'DisplayName', 'Legend1'); % plot stuff that should appear on legend
h2 = plot(. . ., 'DisplayName', 'Legend2'); % plot more stuff that goes on the legend
h3 = plot(. . . ); % Polkadots
% at the end of the plotting stuff
legend([h1,h2])
  8 件のコメント
shane watson
shane watson 2019 年 12 月 13 日
You are real mentor @Adam Danz, I will keep you in my loop for the help. (I sent you a message can you respond to that).
Thank you
Adam Danz
Adam Danz 2019 年 12 月 14 日
Thank you, Shane; glad I can help out!
Just FYI, I didn't receive a message, in case it's important.

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

その他の回答 (0 件)

カテゴリ

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