Post-formatting of figures

2 visualizzazioni (ultimi 30 giorni)
Kai
Kai il 29 Mar 2024
Commentato: Voss il 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!

Risposta accettata

Voss
Voss il 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 Commenti
Kai
Kai il 29 Mar 2024
Many thanks! that's what I was looking for
Voss
Voss il 29 Mar 2024
You're welcome!

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by