Plot multiple Lines and keep them in one handle

6 ビュー (過去 30 日間)
bigsmile96
bigsmile96 2017 年 7 月 20 日
コメント済み: Javier Cabello 2020 年 5 月 29 日
Hi everybody,
I want to plot many (round about 30.000) 2D-lines in a plot. A line has only change in y-axis.
For example:
tolerance_1 = [2 3 4 5 6 7 8];
tolerance_2 = [1 2 3 4 5 6 7];
x = [1 2 3 4 5 6 7];
line1 = plot ([x(1) x(1)], [tolerance_1(1) tolerance_2(1)], 'r-');
It is no problem to plot all the lines with a for-loop. But I need to keep for all the lines a handle so I can set the lines visible and invisible. When I create a vector with the length of the number of lines (round about 30.000) and fill it with all the handles, my MATLAB crashes. Is there a possibility to get a single handle to all the lines?
I tried something like that:
mylines = plot([x x],[tolerance_1 tolerance_2],'r-')
But this does not work because the single lines are connected.
Does anybody know a solution?
Thank you very much and have a nice day. :-)
  2 件のコメント
Adam
Adam 2017 年 7 月 20 日
How can you possibly make any sense of a plot with 30,000 lines on it? It sounds like it needs a rethink of what you are doing. Each line will be its own graphics object unless you connect them all to be a single line, but I thought the point of what you wanted was to be able to switch off (make invisible) individual lines anyway?
Stephen23
Stephen23 2017 年 7 月 20 日
編集済み: Stephen23 2017 年 7 月 20 日
30000 lines in one figure? At typical modern monitor sizes (e.g. 1920x1080) those lines would be totally indistinguishable. You would need a monitor with well more than ten times higher resolution... does anything like that even exist? I guess you have a rather large IT budget.

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

採用された回答

Stephen23
Stephen23 2017 年 7 月 20 日
編集済み: Stephen23 2017 年 7 月 20 日
Plotting in a loop is a waste of MATLAB:
tol1 = [2 3,4,5,6,7,8];
tol2 = [1,2,3,4,5,6,7];
x = [1,2,3,4,5,6,7];
lnh = plot([x;x],[tol1;tol2],'*-');
producing:
  3 件のコメント
Javier Cabello
Javier Cabello 2020 年 5 月 29 日
Awesome! I also had a similar problem, just multple straight lines in a plot. Simple and elegant solution, without bending myself backward (and crashing the computer) with loops.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by