Error using sgtitle?
Afficher commentaires plus anciens
I have a subplot with four graphs I'm trying to put my figures title over..
sgtitle('Mean Times per Group',['Over 37.5 = ' num2str(meanover) 'Under 37.5 = ' num2str(meanunder)]);
It accepts the "Mean Times per Group" part but gives me the error below.
Error using matlab.graphics.illustration.subplot.Text/set
Unrecognized property Over 37.5 = 0.97049Under 37.5 = 0.99391 for class Text.
Error in sgtitle (line 98)
set(h, pvpairs{:});
Any ideas why?
Réponse acceptée
Plus de réponses (1)
Voss
le 5 Déc 2021
sgtitle is interpreting the second argument you give it (i.e., ['Over 37.5 = ' num2str(meanover) 'Under 37.5 = ' num2str(meanunder)]) as a property name. That is, it expects property-value pairs after the first argument, in this case.
I don't have access to sgtitle, so I can't say for sure what the solution is, but you can try sending a cell array of character arrays as the first argument, if this is meant to be a two-line title. Like this:
sgtitle({'Mean Times per Group',['Over 37.5 = ' num2str(meanover) 'Under 37.5 = ' num2str(meanunder)]});
Or if that doesn't work, you can send a character array with a newline in it, like this:
sgtitle(sprintf('Mean Times per Group\n%s',['Over 37.5 = ' num2str(meanover) 'Under 37.5 = ' num2str(meanunder)]));
Catégories
En savoir plus sur Printing and Saving dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!