
How to modify the scaling values on yyaxis right?
4 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (1 件)
Cris LaPierre
2018 年 12 月 10 日
編集済み: Cris LaPierre
2018 年 12 月 10 日
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 件のコメント
Cris LaPierre
2018 年 12 月 10 日
編集済み: Cris LaPierre
2018 年 12 月 11 日
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.
参考
カテゴリ
Help Center および File Exchange で Stress and Strain についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!