How to chose the correct line style?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have created the attached plot. I have a large dataset with multiple entries, each representing different moving objects. I want to draw a line plotting the movement of each unique object, per day. This works, but the display is different depending on whether I use scatter or plot. If I use plot, I get the type of line I would like, where the lines are connected, but using scatter, solitary points (that aren't moving) are missed from the plot. How do I choose a line style which allows me to show both the solitary points and connect those points that are related?
For example, I see that I could just plot one of each line style over the top of each other, but then I lose the unique colours attached to each set of data points.
subplot(5,1,1)
unique_MMSI=unique(gps_data.cpa3);
for i=1:height(unique_MMSI)
MMSI=unique_MMSI(i);
S=gps_data.cpa3==MMSI;
gps_sub=gps_data(S,:);
[N,edges,bin] = histcounts(datetime(gps_sub.cpa1,'ConvertFrom','datenum'),'BinMethod','day');
bin_num=unique(bin);
bin_num=bin_num';
for ii=1:width(bin_num)
bin_on=bin_num(ii);
[lia,loc]=ismember(bin,bin_on);
gps_plot=gps_sub(lia,:);
gps_plot.DateTime=datetime(gps_plot.cpa1,'ConvertFrom','datenum');
plot(gps_plot.DateTime,gps_plot.vessel_CPAs)
hold on
end
hold on
end
ylim([0 5])
starttime=datetime(2020,1,1,0,0,0);
endtime=datetime(2020,6,7,0,0,0);
xlim([starttime, endtime]);
xticks(starttime:days(7):endtime); %change range of x-axis using times from .wav
xlim([starttime, endtime]);
xtickangle(0);
3 comentarios
Jonas
el 22 de Jul. de 2021
great to hear it was what you were searching for. i will post the comment as answer below, you can then accept it and then this forum has one question less to be solved
Respuestas (1)
Jonas
el 22 de Jul. de 2021
looks like you have to add a marker to your plot atcommand, then you do not only have lines but also markers during and the ends of the lines
0 comentarios
Ver también
Categorías
Más información sobre Scatter Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!