How do I set back color of figure by pcolor to white?

6 vues (au cours des 30 derniers jours)
Ting Zheng
Ting Zheng le 1 Fév 2020
Commenté : J. Alex Lee le 3 Fév 2020
I try to use set(h,'defaultfigurecolor','white'), but it can't set the background color of figure by pcolor to white.
  4 commentaires
Image Analyst
Image Analyst le 2 Fév 2020
I'm curious as to your reasons for using pcolor() rather than image, imagesc() or imshow()? What are they?
J. Alex Lee
J. Alex Lee le 3 Fév 2020
pcolor naturally treats NaN as missing, which might be what OP needs considering the discussion about background color. Drawback is that you can't set linestyle in-line, but you could argue the pcolor way is simpler:
% C is an image with NaN's meant to be transparent
h1 = pcolor(C);
C.LineStyle = 'none';
% vs
AData = ones(size(C));
AData(isnan(C)) = 0;
h2 = imagesc(C,'AlphaData',AData)
It's also a bit less obstrusive, e.g., doesn't alter existing axis limits
But to be honest, at the time I was interested in pcolor, I completely forgot about the AlphaData property of the image functions.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange

Tags

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by