MATLAB Answers


How to update a contourf plot?

Asked by Rafael Kübler on 12 Dec 2018
Latest activity Commented on by Rafael Kübler on 13 Dec 2018
i know, how to update a surface for example in a for-loop using:
set(hSurf, 'ZData', newZData)
set(hSurf, 'CData', newCData)
but how do i update a contourf plot? Here I quess i need somehow the contour matrix and the ZData.
Thank you for your help in advance.

  1 Comment

on 12 Dec 2018
What effect, specifically, are you after? It appears the ContourMatrix array is read-only; whether there are callbacks internal that trigger recomputation if you change the underlying data of an object I didn't explore and the documentation doesn't explicitly might have to delve much deeper into the bowels depending upon just what you're trying to do.

Sign in to comment.




1 Answer

Answer by Cris LaPierre on 12 Dec 2018
 Accepted Answer

[~,hc] = contourf(Z);
hc.ZData = newZdata;
I don't see a CData property for contourf

  1 Comment

Yes. This works. Thanks.
Updating only ZData of the contourf is enough. The contour lines and the color change automaticly wit ZData.

Sign in to comment.