Multiple lines in one figure
4 次查看(过去 30 天)
显示 更早的评论
I'm plotting some data on top of a map, and I'm trying to add the Dutch Exclusive Economic Zone to the figure but it doesn't want to show.
figure('Color','w');
load NL_region_coast_RD.mat % contains x- and y-coordinates of the Dutch coastline (xRDc and yRDc)
line(xRDc/1000,yRDc/1000,'LineWidth',1.0,'Color','k');
hold on
line(rijksx/1000,rijksy/1000,'LineWidth',1.0,'Color','r'); % x- and y-coordinates of EEZ (rijksx and rijksy)
axis equal
xlim(rdxlim')
ylim(rdylim')
fsize=12;
set(gca,'FontSize',fsize);
set(gca,'YAxisLocation','left')
After this piece of code, I use imagesc to layer my data on top of it (as a colormap). This works on top of the Dutch coastline, but the EEZ just won't show. Does anyone know why, and how to fix it?
3 个评论
Simon Chan
2023-6-21
Is there any possibility that the values of the variables rijksx/1000 and rijksy/1000 is outside the axis limit? Noticed that you already divide EEZx and EEZy in the for loop by 1000 already.
回答(2 个)
Joe Vinciguerra
2023-6-21
The is nothing innately wrong with your code.
Check that the values within rdxlim and rdylim are appropriate for the dataset.
If you can, move imagesc before the lines so it layers the lines on top. If you can't relocate imagesc in your code:
Change the transparency: https://www.mathworks.com/help/matlab/ref/imagesc.html?s_tid=doc_ta#buxkjup_sep_shared-AlphaData
Or change the plotting order like this:
figure("Color", "w")
line([0:1:10], [0:1:10],'LineWidth',1.0,'Color','k');
hold on
line([0:1:10], [0:10:100],'LineWidth',1.0,'Color','r');
imagesc
g=get(gca,'Children');
g=g([3 2 1]);
set(gca,'children',g);
2 个评论
Joe Vinciguerra
2023-6-21
It's there. It's just outside of your limits. And I would guess that it's not scaled correctly. Here is a screenshot of the figure file you provided, zoomed in on the region where your missing data can be found:
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!