Modify Labels on Contour Plots

162 vues (au cours des 30 derniers jours)
Oyeniyi
Oyeniyi le 12 Août 2015
Réponse apportée : Rob Comer le 14 Août 2015
I want to modify the font (size and type) of the text that is obtained when the contour function is implemented with the 'showtext' option set to 'on' as in the example below.
contour(X,Y,Z,'ShowText','on').
I have tried using 'clabel' but this introduces another set of text to the plot.

Réponses (2)

James Wiken
James Wiken le 14 Août 2015
This functionality has been added in the MATLAB R2015b Prerelease. It uses 'clabel' rather than the 'ShowText' option in the 'contour' function. The end result is the same though. Below is an example of changing the font size, color, and type for the labels on a contour plot:
x = linspace(-2*pi,2*pi);
y = linspace(0,4*pi);
[X,Y] = meshgrid(x,y);
Z = sin(X)+cos(Y);
figure
[C,h] = contour(X,Y,Z);
clabel(C,h,'FontSize',15,'Color','r','FontName','Courier')

Rob Comer
Rob Comer le 14 Août 2015
R2014b and R2015a users can apply one of the workarounds available here:
and then use clabel to set FontSize, Color, FontName, FontWeight, and 8 other properties that affect the appearance of text labels. (There's a separate workaround for each release; be sure to download the correct one.) With these updates, R2014b and R2015a are able to run the example given in the answer from James, with identical results.

Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by