# How to modify the scaling values on yyaxis right?

5 views (last 30 days)
Robert Flores on 10 Dec 2018
Edited: Cris LaPierre on 11 Dec 2018
Hello,
I am trying to re-scale my yyaxis right values by making the values: 0_Bot, 0_Top, 17_Bot, 17_Top, -63_Bot, -63_Top, 90_Bot, and 90_top. I get lucky with my first few values actully marking the cuve, but as I go up my values don't match my graph anymore. If you can help me it will be greatly appreciated. Below is a copy of the function I am making for this graph, and in the attahments is a snip of my issue. (I am only concerned with the last part of my code under % Local Stresses)
-Robert
function z_plot(Strain_12,Strain_XY,Stress_XY,Stress_12,Thickness,p)
% This function will output all the graphs for sigma x,y and shear. As
% well as the strains for both Global and Local
Number_of_Ply = length(Stress_XY)/2;
% Global Strains
z_plot = -((Number_of_Ply)/2)*Thickness:Thickness:((Number_of_Ply)/2)*Thickness;
str_ar = ["_x","_y","_x_y"];
figure(4*p+1)
plot(Strain_XY,z_plot,'Linewidth',3);
title_str = "Global Strain in,"+char(949)+str_ar(p+1)+" Measured in mm";
title(title_str)
grid on
xlabel([char(949)+str_ar(p+1)+' Measured in \mu mm/mm'])
yyaxis left
ylabel('z, Measured in mm')
yyaxis right
ylabel('0 0 17 17 -63 -63 90 90')
% Local Strains
z_plot2 = -((Number_of_Ply)/2)*Thickness:Thickness/2:((Number_of_Ply)/2)*Thickness;
z_plot2 = repelem(z_plot2,2);
z_plot2(end) = [];
z_plot2(1) = [];
Local_Strains = repelem(Strain_12,2) ;
figure(4*p+2)
plot(Local_Strains,z_plot2,'Linewidth',3);
title_str = "Local Strains in,"+char(949)+str_ar(p+1)+" Measured in \mu mm/mm";
title(title_str)
grid on
xlabel([char(949)+str_ar(p+1)+' Measured in \mu mm/mm'])
yyaxis left
ylabel('z, Measured in mm')
yyaxis right
ylabel('0 0 17 17 -63 -63 90 90')
% Global Stresses
Global_Stresses = repelem(Stress_XY,2) ;
figure(4*p+3)
plot(Global_Stresses,z_plot2,'Linewidth',3);
title_str = "Global Stresses in,"+char(963)+str_ar(p+1)+" Measured in MPa";
title(title_str)
grid on
xlabel([char(963)+str_ar(p+1)+' Measured in MPa'])
yyaxis left
ylabel('z, Measured in mm')
yyaxis right
set(gca,'YTickLabel',{'0','0_B_O_T','0_T_O_P','17_B_O_T','-63_B_O_T','-63_T_O_P','90_B_O_T','90_T_O_P'})
% Local Stresses
Local_Stresses = repelem(Stress_12,2) ;
figure(4*p+4)
plot(Local_Stresses,z_plot2,'Linewidth',3);
title_str = "Local Stresses in,"+char(963)+str_ar(p+1)+" Measured in MPa";
title(title_str)
grid on
xlabel([char(963)+str_ar(p+1)+' Measured in MPa'])
yyaxis left
ylabel('z, Measured in mm')
yyaxis right
% % ylim([-.01 0.01])
% % yticks(-1:0.002:1)
set(gca,'YTickLabel',{'0','0_B_O_T','0_T_O_P','17_B_O_T','17_T_O_P','-63_B_O_T','-63_T_O_P','90_B_O_T','90_T_O_P'})
ylabel('Layer, \theta')
end

Cris LaPierre on 10 Dec 2018
Edited: Cris LaPierre on 10 Dec 2018
TickLabel knows nothing about the features of your line. The labels are just placed at the spot specified in their corresponding Tick mark. If you want to adjust where the TickLabels should be placed, you need to set the Tick location as well. Incidentally, your '0' and '0_{BOT}' repeat because you specify 9 labels, but there are 11 YTicks, so it just starts reusing the labels from the beginning.
Also, consider taking advantage of the 'tex' interpreter
xlabel('\sigma' + str_ar(p+1) + ' Measured in MPa','Interpreter','tex')
set(gca,'YTickLabel',{'0','0_{BOT}','0_{TOP}','17_{BOT}','17_{TOP}','-63_{BOT}','-63_{TOP}','90_{BOT}','90_{TOP}'})
##### 2 CommentsShowHide 1 older comment
Cris LaPierre on 10 Dec 2018
That depends on the version of MATLAB you are using. I'm in 2018b. There, I click on the "Open Property Inspector' icon in the toolbar (next to the arrow). This icon didn't exist in previous versions (I believe).
The other way can get to there is through the figure menu by clicking View > Property Editor and then clicking on "More Properties...". This works in earlier versions as well, though the view of the Property Inspector might be different.