Plot multiple Lines and keep them in one handle

5 vues (au cours des 30 derniers jours)
bigsmile96
bigsmile96 le 20 Juil 2017
Commenté : Javier Cabello le 29 Mai 2020
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 commentaires
Adam
Adam le 20 Juil 2017
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 le 20 Juil 2017
Modifié(e) : Stephen23 le 20 Juil 2017
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.

Connectez-vous pour commenter.

Réponse acceptée

Stephen23
Stephen23 le 20 Juil 2017
Modifié(e) : Stephen23 le 20 Juil 2017
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 commentaires
Javier Cabello
Javier Cabello le 29 Mai 2020
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by