首页 > 解决方案 > Label the actual data points in y-axis [MATLAB]

问题描述

I have a plot with two plotting by using yyaxis. The grid on the right yyaxis is currently aligned with the left yyaxis according to this. Now I want to also label the actual data points on the right yyaxis. How can I achieve this as illustrated in the following image?

enter image description here

标签: matlabplotaxes

解决方案


You can use the axes YTick and YTickLabel properties. You would just need to be sure that the active side is the right one.

In your example, adding these lines would do the trick:

yyaxis('right');
set(gca,'YTick',[0, 2, 2.8, 5.6, 7, 8.4, 11, 11.2, 14]);

推荐阅读