Why does the ylabel position differ although i use the same code for every figure?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Lucas Junghans
el 20 de Jul. de 2022
Comentada: dpb
el 20 de Jul. de 2022
For 10 different figures i use the same code regarding the ylabel position nevertheless as you can see in the pictures my ylabel differ from each other. Can you please explain it to me, why this happens?
figure(1)
title("DC",FontSize=18)
hold on
plot(var1R1(1:15,1),"LineWidth",2)
plot(var1R2(1:15,1),"LineWidth",2)
plot(var1R3(1:15,1),"LineWidth",2)
plot(var1R4(1:15,1),"LineWidth",2)
hold off
legend("R1","R2","R3","R4","Fontsize",12,"Location","northwest")
xlabel("Widerstandswerte in 1/10 \Omega","FontSize",16)
ylh1 = ylabel("Amplitude relativ zur Grundschwingung in %","Fontsize",16);
ylh1.Position(1) = ylh1.Position(1) + abs(ylh1.Position(1)*0.2);
figure(10)
title("25.",FontSize=18)
hold on
plot(var1R1(136:150,1),"LineWidth",2)
plot(var1R2(136:150,1),"LineWidth",2)
plot(var1R3(136:150,1),"LineWidth",2)
plot(var1R4(136:150,1),"LineWidth",2)
hold off
legend("R1","R2","R3","R4","Fontsize",12,"Location","northwest")
xlabel("Widerstandswerte in 1/10 \Omega","FontSize",16)
ylh10 = ylabel("Amplitude relativ zur Grundschwingung in %","Fontsize",16);
ylh10.Position(1) = ylh10.Position(1) + abs(ylh10.Position(1)*0.2);
Hope you can help me.
Lucas:)
3 comentarios
dpb
el 20 de Jul. de 2022
He's not saying use fixed labels but a fixed-width and consistent format field for the tickk labels -- the default format is %g which lets the number of digits and precision vary depending upon the values. Use a specifc %.2f or similar may minimize the differences in sizes (or may exacerbate, I don't know w/o trying) and so the spacing/location auto-selected for the label may be closer to the same.
Look at the position by default from the legends and see just what those differences are before you mess around with it -- the default position is computed in data units; alternatively, you could set to 'normalized' and use the same relative position overall. This will end up with the label in identical position on the figure, but different distance from the tck labels themselves.
It's not clear what effect you're trying to achieve and what difference it would make...
Respuesta aceptada
Lucas Junghans
el 20 de Jul. de 2022
Editada: Lucas Junghans
el 20 de Jul. de 2022
1 comentario
dpb
el 20 de Jul. de 2022
That was my suggestion above -- although depending on the actual y tick values, the spacing may get close if the tick values have more digits. But the actual postion of the label will be constant.
Más respuestas (0)
Ver también
Categorías
Más información sobre Axis Labels en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!