Here are two methods to show ticks only on the left axis.
Use yyaxis
This method creates a 2nd y axis on the right that is independently customizable and not used (unless you want to use it).
ax = axes();
box(ax, 'on')
ax.XAxis.TickLength = [0 0];
ax.YAxis.TickDirection = 'both';
yyaxis right
ax2 = gca();
ax.YAxis(1).Color = ax.XAxis.Color;
ax.YAxis(2).Color = ax.XAxis.Color;
ax.YAxis(2).TickValues = [];
yyaxis left
See image below for results.
Use xline and yline at axis limits
ax = axes();
box(ax, 'off')
ax.XAxis.TickLength = [0 0];
If you want the y-ticks to be in both directions,
ax.YAxis.TickDirection = 'both';
If you want the right and upper axes lines but without ticks, you can make is appear as though 'box' is 'on' by setting the axis limits and adding a xline and yline.
xlim(ax, xlim(ax))
ylim(ax, ylim(ax))
xline(max(xlim(ax)), 'k-', 'Color', ax.XAxis.Color)
yline(max(ylim(ax)), 'k-', 'Color', ax.YAxis.Color)
If the axis limits change after this change, the pseudo-box lines will no longer be positioned correctly so this should happen after all other plotting and positioning is done on the axes. The first method is therefore safer.
Final result for both methods
Best Answer