2
votes

I was given MATLAB figure files with four subplots. The last subplot has two y axes, and I need to change the font size of the second y axis. I do not have the original data, only the figure files. How do I do this?

1
I'm looking specifically at how to change subplot properties without access to the original data. I only have a .fig file.Jen
The same solution from the other question applies here, you just have to get a handle to the axis you want (FINDOBJ). I added an answer showing howAmro
"you just have to get a handle to the axis you want" I think this was part of the problem, I didn't know the name of or how to access the handle that I needed.Jen

1 Answers

3
votes

First let's create a figure similar to what you described, and save it to a FIG file:

for i=1:3
    subplot(2,2,i)
    plot(rand(10,1))
end
subplot(224), plotyy(1:10, rand(10,1), 1:10, randn(10,1))

hgsave myfigure.fig

Now we load the figure from file, and look for the second axis of PLOTYY. Once we have its handle, we can change any property we want.

hFig = hgload('myfigure.fig');
hAx = findobj(hFig, 'type','axes', '-and', 'YAxisLocation','right');
set(hAx, 'FontSize',16, 'XTick',[])

Just keep in mind that the way PLOTYY works is by creating two superimposed axes, each with its own x/y-labels. That's why I suppress the x-labels for the second when I change the font size, to avoid seeing two sets of labels on top of each other (each in a different font size).

Screenshot