Different X axis location. Unsure Why.
I am performing two very similar plots but the placement of the xlabel is different and I cant determine why or how to rectify it. I would prefer to force the xlabel to be as in my first example:
%clearing crap
clear all
clf
%selecting amazing font
set(0, "DefaultAxesFontName", "Courier New");
set(0, "DefaultTextFontName", "Courier New");
%importing required data
%importing data
Raman = readtable("Pfile.csv");
%converting data
shift = table2array(Raman(:,1));
MW0 = table2array(Raman(:,2));
AlMW25 = table2array(Raman(:,3));
AlMW5 = table2array(Raman(:,4));
%plotting MW0
plot(shift, MW0)
hold on %plotting on same graph
plot(shift, AlMW25)
plot(shift, AlMW5)
hold off %end of plotting
%beautifying curve
ax = gca;
ax.XAxisLocation = "origin";
ax.YAxisLocation = "origin";
box off;
%labelling graph
xlabel("Raman Shift [cm^{-1}]");
ylabel("Intensity [Arb. Units.]");
title("Raman Spectra")
legend("MW 0","AlMW 2.5","AlMW 5","Location","north west")
This returns the following graph:
In example two i get the following:
%clearing crap
clear all
clf
%selecting amazing font
set(0, "DefaultAxesFontName", "Courier New");
set(0, "DefaultTextFontName", "Courier New");
%importing required data
%importing data
Raman = readtable("Ufile5.csv");
%converting data
shift0 = table2array(Raman(:,1));
NBS0 = table2array(Raman(:,2));
shift1 = table2array(Raman(:,3));
NBS1 = table2array(Raman(:,4));
shift2 = table2array(Raman(:,5));
NBS2 = table2array(Raman(:,6));
shift3 = table2array(Raman(:,7));
NBS3 = table2array(Raman(:,8));
shift4 = table2array(Raman(:,9));
NBS4 = table2array(Raman(:,10));
%plotting NBS0
plot(shift0, NBS0)
hold on %plotting on same graph
plot(shift1, NBS1)
plot(shift2, NBS2)
plot(shift3, NBS3)
plot(shift4, NBS4)
hold off %end of plotting
%beautifying curve
ax = gca;
ax.XAxisLocation = "origin";
ax.YAxisLocation = "origin";
box off;
xlabel("Raman Shift [cm^{-1}]"); % Store handle
ylabel("Intensity [Arb. Units.]");
title("Raman Spectra for NBS Glasses");
legend("NBS 0", "NBS 1", "NBS 2", "NBS 3", "NBS 4", "Location", "northwest");
and i get the followign less optimal xlabel position:I am performing two very similar plots but the placement of the xlabel is different and I cant determine why or how to rectify it. I would prefer to force the xlabel to be as in my first example:
%clearing crap
clear all
clf
%selecting amazing font
set(0, "DefaultAxesFontName", "Courier New");
set(0, "DefaultTextFontName", "Courier New");
%importing required data
%importing data
Raman = readtable("Pfile.csv");
%converting data
shift = table2array(Raman(:,1));
MW0 = table2array(Raman(:,2));
AlMW25 = table2array(Raman(:,3));
AlMW5 = table2array(Raman(:,4));
%plotting MW0
plot(shift, MW0)
hold on %plotting on same graph
plot(shift, AlMW25)
plot(shift, AlMW5)
hold off %end of plotting
%beautifying curve
ax = gca;
ax.XAxisLocation = "origin";
ax.YAxisLocation = "origin";
box off;
%labelling graph
xlabel("Raman Shift [cm^{-1}]");
ylabel("Intensity [Arb. Units.]");
title("Raman Spectra")
legend("MW 0","AlMW 2.5","AlMW 5","Location","north west")
This returns the following graph:
In example two i get the following:
%clearing crap
clear all
clf
%selecting amazing font
set(0, "DefaultAxesFontName", "Courier New");
set(0, "DefaultTextFontName", "Courier New");
%importing required data
%importing data
Raman = readtable("Ufile5.csv");
%converting data
shift0 = table2array(Raman(:,1));
NBS0 = table2array(Raman(:,2));
shift1 = table2array(Raman(:,3));
NBS1 = table2array(Raman(:,4));
shift2 = table2array(Raman(:,5));
NBS2 = table2array(Raman(:,6));
shift3 = table2array(Raman(:,7));
NBS3 = table2array(Raman(:,8));
shift4 = table2array(Raman(:,9));
NBS4 = table2array(Raman(:,10));
%plotting NBS0
plot(shift0, NBS0)
hold on %plotting on same graph
plot(shift1, NBS1)
plot(shift2, NBS2)
plot(shift3, NBS3)
plot(shift4, NBS4)
hold off %end of plotting
%beautifying curve
ax = gca;
ax.XAxisLocation = "origin";
ax.YAxisLocation = "origin";
box off;
xlabel("Raman Shift [cm^{-1}]"); % Store handle
ylabel("Intensity [Arb. Units.]");
title("Raman Spectra for NBS Glasses");
legend("NBS 0", "NBS 1", "NBS 2", "NBS 3", "NBS 4", "Location", "northwest");
and i get the followign less optimal xlabel position: I am performing two very similar plots but the placement of the xlabel is different and I cant determine why or how to rectify it. I would prefer to force the xlabel to be as in my first example:
%clearing crap
clear all
clf
%selecting amazing font
set(0, "DefaultAxesFontName", "Courier New");
set(0, "DefaultTextFontName", "Courier New");
%importing required data
%importing data
Raman = readtable("Pfile.csv");
%converting data
shift = table2array(Raman(:,1));
MW0 = table2array(Raman(:,2));
AlMW25 = table2array(Raman(:,3));
AlMW5 = table2array(Raman(:,4));
%plotting MW0
plot(shift, MW0)
hold on %plotting on same graph
plot(shift, AlMW25)
plot(shift, AlMW5)
hold off %end of plotting
%beautifying curve
ax = gca;
ax.XAxisLocation = "origin";
ax.YAxisLocation = "origin";
box off;
%labelling graph
xlabel("Raman Shift [cm^{-1}]");
ylabel("Intensity [Arb. Units.]");
title("Raman Spectra")
legend("MW 0","AlMW 2.5","AlMW 5","Location","north west")
This returns the following graph:
In example two i get the following:
%clearing crap
clear all
clf
%selecting amazing font
set(0, "DefaultAxesFontName", "Courier New");
set(0, "DefaultTextFontName", "Courier New");
%importing required data
%importing data
Raman = readtable("Ufile5.csv");
%converting data
shift0 = table2array(Raman(:,1));
NBS0 = table2array(Raman(:,2));
shift1 = table2array(Raman(:,3));
NBS1 = table2array(Raman(:,4));
shift2 = table2array(Raman(:,5));
NBS2 = table2array(Raman(:,6));
shift3 = table2array(Raman(:,7));
NBS3 = table2array(Raman(:,8));
shift4 = table2array(Raman(:,9));
NBS4 = table2array(Raman(:,10));
%plotting NBS0
plot(shift0, NBS0)
hold on %plotting on same graph
plot(shift1, NBS1)
plot(shift2, NBS2)
plot(shift3, NBS3)
plot(shift4, NBS4)
hold off %end of plotting
%beautifying curve
ax = gca;
ax.XAxisLocation = "origin";
ax.YAxisLocation = "origin";
box off;
xlabel("Raman Shift [cm^{-1}]"); % Store handle
ylabel("Intensity [Arb. Units.]");
title("Raman Spectra for NBS Glasses");
legend("NBS 0", "NBS 1", "NBS 2", "NBS 3", "NBS 4", "Location", "northwest");
and i get the followign less optimal xlabel position: plot, xlabel MATLAB Answers — New Questions