"hold on" strangely doesn't work after contourf()

Viewed 93

I am trying to plot a vertical line on top of the current plot, but for some reason "hold on + plot()" doesn't work in this case. How could it be done?

figure1=figure(4)
axes1 = axes('Parent',figure1,'YScale','log','XScale','log','Layer','top');
grid(axes1,'on');
hold(axes1,'on');
[C,h]=contourf(peaks,[10],'LineColor','none');
clabel(C,h);
hold on %doesn't work
plot([10 10],[0 10],'--k','LineWidth',2) %doesn't work
axis tight;    
axis([1 50 1 50]) 
xlabel('\lambda_x','Fontsize',20);
ylab=ylabel('y^+','Fontsize',20);
grid off
set(ylab, 'Units', 'Normalized', 'Position', [-0.1, 0.5, 0]);
set(gca,'linewidth',1.5,'FontSize',16)
colormap(flipud(gray(256)));
colorbar;

ax2 = axes('Position',axes1.Position,'YScale','log','XScale','log','XAxisLocation','top','YAxisLocation','right','Color','none','YTick',[]);
xla2=xlabel(ax2,'\lambda_x^+','Fontsize',20);
axis(ax2,[1*100 50*100 1*100 50*100]) 
set(ax2,'linewidth',1.5,'FontSize',16)

enter image description here

1 Answers

It's not the hold on that doesn't work. Change your plot line to something like this:

plot([10 10],[1e-10 10],'--k','LineWidth',2)

Note that 0 should be drawn at -inf in logarithmic scale. That sometimes causes problems.

Related