Set axes and other properties with only one command
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Tommaso Scali
el 23 de En. de 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 comentarios
Stephen23
el 23 de En. de 2019
Editada: Stephen23
el 23 de En. de 2019
"I mean I don't wanna use the command set for each plot to change for example"
You don't need to: exactly as the set help states, you can simply supply all of the axes handles in one array as the first input argument and call set once.
Respuesta aceptada
Stephen23
el 24 de En. de 2019
Editada: Stephen23
el 24 de En. de 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 comentarios
Stephen23
el 24 de En. de 2019
Editada: Stephen23
el 24 de En. de 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')

Más respuestas (0)
Ver también
Categorías
Más información sobre Printing and Saving en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!