Set axes and other properties with only one command
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Tommaso Scali
le 23 Jan 2019
Modifié(e) : Stephen23
le 24 Jan 2019
I wanted to ask how we can set the properties of all axes only with a command. I mean I don't wanna use the command set for each plot to change for example the 'FontSIze' and all the oher features.
Thank you a lot, you do always a wonderful job, best regards,
Tommaso
2 commentaires
Réponse acceptée
Stephen23
le 24 Jan 2019
Modifié(e) : Stephen23
le 24 Jan 2019
"Ok, but what about the different fontsize for the numbers in the axes, the legend and so on?"
Sure. Read the set documentation, and you will see that you can set different values for each of the handles with just one set call: " set(H,NameArray,ValueArray) specifies multiple property values using the cell arrays NameArray and ValueArray. To set n property values on each of m graphics objects, specify ValueArray as an m-by-n cell array, where m = length(H) and n is equal to the number of property names contained in NameArray."
A simple example with two objects, one property, and each object getting a different value:
ax(1) = axes(...);
ax(2) = axes(...);
set(ax,{'fontsize'},{12;20})
The second cell array must have as many columns as the number of properties you specify in the first cell array. There is no practical limit to how many objects and how many properties you can set with one set call.
2 commentaires
Stephen23
le 24 Jan 2019
Modifié(e) : Stephen23
le 24 Jan 2019
What are these lines supposed to do?:
ax(1)=axes('Title');
ax(2)=axes('FontSize');
The axes command creates an axes object, and its permitted input arguments are explained in the documentation. While there certainly are axes properties with names matching the ones you used, you did not use any (required!) values to accompany them. It is not clear what you expect the result of those commands to be.
Note that if you expect to get two separate visible axes you will need to use subplot, or create them in different figures, or use set to change their positions:
>> ax(1) = axes();
>> ax(2) = axes();
>> set(ax,{'position'},{[0.1,0.1,0.35,0.8];[0.55,0.1,0.35,0.8]})
>> saveas(gcf,'setaxes.png')

Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Printing and Saving dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!