Overlay contour and line plot
显示 更早的评论
Hi Folks, I've got a 2D contour plot (x,y,z) and I want to overlay a line plot (x,y). The two graphs share the same x values. The hold on functions don't seem to help much. Any pointers?

fig1 = figure(1);
hFig = contour(gEmiFreq,gAbsFreq,MAmpl,c0.*SFac,...
'LineStyle','-','LineWidth',CntlineW);
line(DiagnlLine(1,:), DiagnlLine(2,:), 'LineStyle', '-', 'Color', [0 0 0],'LineWidth',LineW+.5);
axis(AxisDim);
caxis([0 1]);
set(gca,'xtickMode', 'manual', 'ytickMode', 'manual','LineWidth',2);
axis square; colormap jet;% colorbar;
hold on
plot(gEmiFreq(1,:),NormRef);
Normref is a 1x1024 laser spectrum and MAmpl,gEmiFreq, and gAbsFreq are 76x1024 arrays
回答(1 个)
Star Strider
2015-1-19
0 个投票
I don’t know what the problem is, since what you describe should work. You didn’t post your code, so I can’t respond with a specific solution.
9 个评论
Star Strider
2015-1-19
I don’t have your data, so I can’t run your code.
See if rearranging your code to put the hold calls in a different order solves your problem:
fig1 = figure(1);
hFig = contour(gEmiFreq,gAbsFreq,MAmpl,c0.*SFac,...
'LineStyle','-','LineWidth',CntlineW);
hold on
line(DiagnlLine(1,:), DiagnlLine(2,:), 'LineStyle', '-', 'Color', [0 0 0],'LineWidth',LineW+.5);
plot(gEmiFreq,NormRef);
hold off
axis(AxisDim);
caxis([0 1]);
set(gca,'xtickMode', 'manual', 'ytickMode', 'manual','LineWidth',2);
axis square; colormap jet;% colorbar;
Image Analyst
2015-1-19
Can you demo with something standard, like the peaks() image?
Star Strider
2015-1-19
I have no idea. I cannot run your code, so I can only wish you luck.
Brian
2015-1-20
Star Strider
2015-1-20
My pleasure!
Is your problem solved?
Brian
2015-1-20
Brian
2015-1-20
Star Strider
2015-1-20
You probably won’t be able to overlay it on the contour plot, unless you use something like plotyy. The reason is that the y values are so different. Experiment with that to see if it solves your problem.
类别
在 帮助中心 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!