What code to make figure window fullscreen with subplot?
Mostra commenti meno recenti
Hello everyone,
I am not a huge matlab user, I know the basics but I don't use it that much.
I created a script that opens a .txt file containing datas from an experiment, reads it, extracts the informations needed, plots 3 curves in a unique figures and then saves the figure created as a .jpg. It works fine, except it saves the Figure (3 subplots) as it appears in the "reduced" window, and I want to save it as the fullscreen window. Basically what I want to do is to add a line of code right before I save the picture that will make the Figure window fullscreen.
I saw some solutions like:
set(B,'PaperPositionMode', 'auto')
set(B,'Units','Normalized','Outerposition',[0 0 1 1]);
that work for only one plot, but when I tried to use it for my 3 plots it ended up making the third set of datas take the whole screen. Basically all I could find on internet doesn't seem to work for subplots.
Here is my code, do you have any suggestions?
Many thanks
clear
close all;
filename='24-09-2019_14-20-2001Theo_sample_100x_diluted_MD_ladder_in_240_mM_trisches_buffer_30_cm_50_um_capillary_25kV.dat.asc';% Your file to be plotted
data0=dlmread(filename,'\t');%get info that are on the text file
totaldatapointsRFU=data0(9,2);%infos needed to plot the datas
totaldatapointskV=data0(9,3);
totaldatapointsA=data0(9,4);
samplerateRFU=data0(8,2);
sampleratekV=data0(8,3);
samplerateA=data0(8,4);
xaxismultiplierRFU=data0(12,2);
yaxismultiplierRFU=data0(13,2);
xaxismultiplierkV=data0(12,3);
yaxismultiplierkV=data0(13,3);
xaxismultiplierA=data0(12,4);
yaxismultiplierA=data0(13,4);
dataRFU=data0(14:(13+totaldatapointsRFU),1)*yaxismultiplierRFU;%First set of datas located in the .txt file
timeRFU=linspace(0,totaldatapointsRFU/samplerateRFU,totaldatapointsRFU);%Time vector for the first datas
datakV=data0((14+totaldatapointsRFU):(13+totaldatapointsRFU+totaldatapointskV),1)*yaxismultiplierkV;%Second set of datas
timekV=linspace(0,totaldatapointskV/sampleratekV,totaldatapointskV);
dataA=data0((14+totaldatapointsRFU+totaldatapointskV):(13+totaldatapointsRFU+totaldatapointskV+totaldatapointsA),1)*yaxismultiplierA;%Thrid set of datas
timeA=linspace(0,totaldatapointsA/samplerateA,totaldatapointsA);
subplot(2,2,1)% Plot of the first set of datas
A=plot(timekV/60,datakV,'LineWidth',3);
xlabel('Time in minutes','FontSize',20,'FontWeight','bold','Color','k')%First argument is the x-axis name
xlim([0 1.1*max(timekV)/60])
ylabel('Tension in kV','FontSize',20,'FontWeight','bold','Color','k')%First argument is the y-axis name
ylim([1.1*min(datakV) 1.1*max(datakV)])
%set(A,'PaperPositionMode', 'auto')
%set(A,'Units','Normalized','Outerposition',[0 0 1 1]);
subplot(2,2,2)% Plot of the second set of datas
B=plot(timeA/60,dataA,'LineWidth',3);
xlabel('Time in minutes','FontSize',20,'FontWeight','bold','Color','k')%First argument is the x-axis name
xlim([0 1.1*max(timeA)/60])
ylabel('Current in µA','FontSize',20,'FontWeight','bold','Color','k')%First argument is the y-axis name
ylim([1.1*min(dataA) 1.1*max(dataA)])
%set(B,'PaperPositionMode', 'auto')
%set(B,'Units','Normalized','Outerposition',[0 0 1 1]);
subplot(2,2,[3,4]) %plot of the third set of datas
C=plot(timeRFU/60, dataRFU, 'LineWidth', 3);
xlabel('Time in minutes','FontSize',20,'FontWeight','bold','Color','k')%First argument is the x-axis name
xlim([0 1.1*max(timeRFU)/60])
ylabel('RFU','FontSize',20,'FontWeight','bold','Color','k')%First argument is the y-axis name
ylim([1.1*min(dataRFU) 1.1*max(dataRFU)])
%set(C,'Units','Normalized','Outerposition',[0 0 1 1]);
%set(C,'PaperPositionMode', 'auto')
set(gca,'FontSize',20)
%set(gca,'Units','Normalized','Outerposition',[0 0 1 1]);
title('100x diluted MD ladder in 25 mM LiAc buffer, 30 cm 50 µm capillary','FontSize',20,'FontWeight','bold','Color','k')%First argument is the title
filename1=erase(filename,'.dat.asc');%Saves the plot in a file with the same name but as a JPG
saveas(gcf,[filename1 '.jpg'])
2 Commenti
Rik
il 25 Set 2019
So you want to maximize the figure before making the image?
Théo Liénard--Mayor
il 25 Set 2019
Risposta accettata
Più risposte (1)
Bruno Luong
il 25 Set 2019
Modificato: Bruno Luong
il 25 Set 2019
1 voto
Check out This thread hope it's not obsolete. If you run on Windows WindowAPI (Jan's reply) is the only one which makes real full-screen display (no border...)
2 Commenti
Théo Liénard--Mayor
il 30 Set 2019
Bruno Luong
il 30 Set 2019
Here is the image I get win WinAPI (I have an old version, syntax might varies)

close all
plot(rand(1,100))
WindowAPI(get(gcf,'Number'),'Position','full')
saveas(gcf,'fullscreentest.jpg')
Categorie
Scopri di più su Subplots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

