Multiple lines in one figure

4 visualizaciones (últimos 30 días)
Lise
Lise el 21 de Jun. de 2023
Respondida: Lise el 21 de Jun. de 2023
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 comentarios
Lise
Lise el 21 de Jun. de 2023
I am afraid that the files I'm using are private... I'm writing my bachelor's thesis at the moment, and the files have been provided by my supervisor. To run this code, 4 different files are required and I can't share them. However, I know that said code and data works as it should. They are simply two arrays, one for x-coordinates and one for y-coordinates (both 39551x1 doubles). This is the entire code I wrote myself, and below is the result.
load NL_region_coast_RD.mat
bplot=10; % additional zone beyond area covered by stations
rdxlim=[-210 350]; % [km]
rdylim=[300 1100];
% loading EEZ data
filen='NL_Exclusive_Economic_Zone__EEZ__may2023.csv';
fid=fopen(filen,'r');
D=textscan(fid,'%s%f%f%f%d%s%s%f%f%f%f%f%f', 'delimiter',',', 'Headerlines',1);
fclose(fid);
xdeg=D{1};
xdeg=str2double(xdeg);
xmin=D{2};
xsec=D{3};
ydeg=D{4};
ymin=D{5};
ymin=double(ymin);
ysec=D{6};
ysec=str2double(ysec);
EEZlen=length(xdeg);
rijksx=zeros(EEZlen,1);
rijksy=zeros(EEZlen,1);
% converting EEZ data: dms --> decimal deg --> rijksdriehoek
xcor=xdeg+(xmin/60)+(xsec/3600);
ycor=ydeg+(ymin/60)+(ysec/3600);
for i=1:EEZlen
[EEZx,EEZy]=wgs2rd(xcor(i),ycor(i));
rijksx(i)=EEZx/1000;
rijksy(i)=EEZy/1000;
end
% plotting country borders
figure('Color','w');
line(xRDc/1000,yRDc/1000,'LineWidth',1.0,'Color','k');
hold on
line(rijksx/1000,rijksy/1000,'LineWidth',1.0,'Color','r');
% axes handling
axis equal
xlim(rdxlim')
ylim(rdylim')
fsize=12;
set(gca,'FontSize',fsize);
set(gca,'YAxisLocation','left')
Simon Chan
Simon Chan el 21 de Jun. de 2023
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.

Iniciar sesión para comentar.

Respuestas (2)

Joe Vinciguerra
Joe Vinciguerra el 21 de Jun. de 2023
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:
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 comentarios
Lise
Lise el 21 de Jun. de 2023
I have set the opacity of the imagesc to 0.5, and the coastlines are visible on top. The issue is that the part:
line(rijksx/1000,rijksy/1000,'LineWidth',1.0,'Color','r');
does not show at all, any way I seem to try. I have tried changing the order, plotting the coast lines over the imagesc and it works, but the EEZ still does not show.
Joe Vinciguerra
Joe Vinciguerra el 21 de Jun. de 2023
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:

Iniciar sesión para comentar.


Lise
Lise el 21 de Jun. de 2023
I figured it out. I switched latitude and longitude, and the data was rotated 90 degrees, so I used rot90 to fix it. It works now! Thanks for the help

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by