Line Plot with Markers possible?

4 ビュー (過去 30 日間)
Jan w
Jan w 2016 年 12 月 29 日
回答済み: Image Analyst 2016 年 12 月 29 日
Hello,
I am plotting a dataset and, as you can see, when a hysteresis is closed he gets back to a certain point. That's what the code does and that is good so far but in the plot he jumps to that certain point and plots a line:
When the plotting is done with a marker the line won't appear.
I'd prefer to use a line plot. Is there a trick to avoid "jumping-lines" in a line plot or maybe use lines in a marker-plot?
my code:
hp=plot(0,0, 'o'); %initial plot
for i=1: ...
%calculating stress - strain relation, then
set(hp,'xdata',Eps(1:i),'ydata',Sig(1:i))
pause(0.1)
drawnow
end
Regards
  1 件のコメント
dpb
dpb 2016 年 12 月 29 日
To break a line, introduce a NaN value after the last valid point prior to the next; it'll be in the [X|Y]Data arrays, but plot and friends will ignore it so won't show.
Alternatively, when get to the end of one loop, instead of continuing with that line, start a new one and the next data point; to do this you'll need an array of line handles that can increment as needed.

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

採用された回答

Walter Roberson
Walter Roberson 2016 年 12 月 29 日
To avoid "line jumping" you need to insert a NaN or Inf into the data at the place you want the break to appear.
You can get a line plot by changing
hp=plot(0,0, 'o'); %initial plot
to something like
hp=plot(0,0, '-'); %initial plot
  1 件のコメント
Jan w
Jan w 2016 年 12 月 29 日
yep this helps! thanks

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2016 年 12 月 29 日
To plot both a line and a marker at the same time, put both along with the colro in the single quotes. For example to plot a red line with asterisks:
plot(x, y, 'r*-', 'LineWidth', 2, 'MarkerSize', 15);
grid on;
Adapt as needed.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by