How do you pause rendering of a figure until you're done setting properties?
22 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Brian Gordon
am 12 Nov. 2018
Beantwortet: Steven Lord
am 12 Nov. 2018
I have a script that creates a plot and then sets 9 different properties on that plot:
heat = heatmap( ... )
heat.ColorMethod = ...
heat.MissingDataColor = ...
heat.MissingDataLabel = ...
heat.YLabel = ...
heat.XLabel = ...
heat.Title = ...
heat.CellLabelColor = ...
heat.Colormap = ...
It seems that what MATLAB is doing is rendering the original plot, then setting the first property and rendering the whole thing again, then setting the second property and rendering the whole thing again, and so on until all of the properties are set.
Rendering the same figure nine times when I only need the final render seems ridiculous. Is this indeed what's happening? If so, is it possible to tell MATLAB to wait until all of the properties are set until rendering the heatmap? I saw the drawnow function in the documentation which seems to imply that there is some kind of buffering of graphics updates going on, but is there any way to control it beyond flushing the buffer with drawnow?
0 Kommentare
Akzeptierte Antwort
Steven Lord
am 12 Nov. 2018
Specify the property names and values in the heatmap call itself as a series of name-value pair arguments. See the example in the "Name-Value Pair Arguments" section on the heatmap documentation page.
Alternately you can call the set function to set multiple properties at once. In fact, in some cases you must do this, like when you want to change the XData and YData properties of a line created by plot to different sized data.
>> h = plot(1:10, 1:10);
>> h.XData = 1:11;
Warning: Error creating or updating Line
Error in value of one or more of the following properties: XData YData
Array is wrong shape or size
>> h.YData = 1:11;
>> set(h, 'XData', 1:12, 'YData', 1:12);
The line disappears when the second line issues the warning and reappears when the condition that caused the warning is corrected on the third line. The last line changes the X and Y data simultaneously and does not issue a warning.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!