Why can't I display a line on a plot (can only have points marker)
Mostra commenti meno recenti
I'm trying to plot a line (x1,y1) on a plot where I applied a mask for land (green) and seas (blue). Whatever the LineSpec I try to use it only displays marker points instead of a line.
I tried to plot the three different options below (plt1, plt2, plt3). I get (x1,y1) in the first case, but it displays points instead of a continuous line as expected (matlab_fig1.png). In the second (matlab_fig2.png) and third case (matlab_fig3.png), I don't get anything.
Here is my code:
%Plot in cartesian coordinates
%Make Land mask
load([pwd '/Grid/bathyEASE.mat']); % load bathymetry
Land=NaN(361,361);
Land(bathyEASE>0)=1;
Land(bathyEASE<0)=0;
%plot
nexttile
hold on; box on;
xlim([0 361]);
ylim([0 361]);
p=pcolor(Land);
colormap(winter);
set(p,'facealpha',0.5)
shading flat;
axis ij;
x1 = [159:163];
y1 = 77;
plt1 = plot(x1,y1,'-r','LineWidth',3,'Marker','.','MarkerEdgeColor','r'); %Refer to --> matlab_fig.png
%plt2 = plot(x1,y1,'-r','LineWidth',3); %Refer to --> matlab_fig2.png
%plt3 = plot(x1,y1); %Refer to --> matlab_fig3.png
Thank you
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Data Distribution Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!