Figure difference in laptop and external monitor

6 views (last 30 days)
Greetings,
I have been trying to figure out why my script generates figures that considerably differ in size depending on whether they are displayed in an external monitor as opposed to the laptop screen. Here is the code I am using (X and Y contain the data I am plotting):
%
% Get the screen size
scrnsize=get(0,'ScreenSize');
%
% Figure position, width, and height as fractions of screen size
figX=1;
figY=scrnsize(4);
figW=round(0.5*scrnsize(3));
figH=round(3*figW/4);
% Create figure
figure1 = figure;
% Create axes
axes1 = axes('Parent',figure1);
set(axes1,'FontName','Arial','FontSize',24,'LineWidth',1.5);
hold(axes1,'on');
%
set(figure1, 'Position', [figX, figY, figW, figH]);
plot1 = plot(X,Y,'Parent',axes1,'LineWidth',2,'Color',[0 0 0]);
set(plot1(1),'DisplayName','Numerical Derivative',...
'MarkerSize',20,'Marker','o',...
'LineWidth',0.5,'LineStyle',':','Color',[0.25 0.25 0.25]);
set(plot1(2),'DisplayName','Functional Fit');
xlabel('Time (s)');
ylabel('Velocity (m/s)');
legend1 = legend(axes1,'show');
set(legend1,'Position',[0.65 0.15 0.20 0.15],'FontSize',20,...
'EdgeColor',[1 1 1]);
xlim(axes1,[0 ceil(max(X))]);
ylim(axes1,[floor(min(min(Y))) ceil(max(max(Y)))]);
The outcome of the above appears as follows on my external monitor:
However, it changes to this when I run the script on my laptop:
I am out of ideas; hopefully, you can help. Thank you in advance for your replies.

Accepted Answer

Marcos Chaos
Marcos Chaos on 10 Mar 2017
Never mind, I just found why this is happening here:
It appears this has no solution at present. I actually thought that the first command of my script would capture the size of the current display, but it actually returns the size of the display the MATLAB session was opened on.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!