Effacer les filtres
Effacer les filtres

Post-formatting of figures

3 vues (au cours des 30 derniers jours)
Kai
Kai le 29 Mar 2024
Commenté : Voss le 29 Mar 2024
Hello all,
Some time ago, I saved some figures. Now that I want to use them, I am wondering if I can change the text size and color afterwards. It is not easy to read.
I found this, but I am not sure if it works on an already existing figure. Does anyone have any ideas? Due to its size I cannot attach the .fig file here, so I added a screenshot.
Many thanks!

Réponse acceptée

Voss
Voss le 29 Mar 2024
You can open the saved figure with the openfig function.
f = openfig('figure1.fig');
You can modify any property of the figure or anything in the figure. But you have to know how to find the object(s) you want to modify. findall can be used for that.
For example, modify the colors and sizes of the x/yticklabels of the axes:
f = openfig('figure1.fig');
ax = findall(f,'Type','axes')
ax =
Axes (title) with properties: XLim: [0 10] YLim: [1 10] XScale: 'linear' YScale: 'linear' GridLineStyle: '-' Position: [0.1300 0.1100 0.7750 0.8150] Units: 'normalized' Use GET to show all properties
ax.XColor = [0 1 1]; % cyan
ax.YColor = [1 0 1]; % magenta
ax.FontSize = 16; % font size of all tick labels
The axes x/ylabels and titles are text objects, so you can use findall to find all text objects in the figure, then modify their properties:
t = findall(f,'Type','text')
t =
3×1 Text array: Text (title) Text (x) Text (y)
t(1).Color = [1 0 0]; % make title red
t(2).Color = [0 1 0]; % make xlabel green
t(3).Color = [0 0 1]; % make ylabel blue
set(t,'FontSize',16) % make all 3 into 16-point size
  2 commentaires
Kai
Kai le 29 Mar 2024
Many thanks! that's what I was looking for
Voss
Voss le 29 Mar 2024
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by