How to chose the correct line style?
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Jonas
2021 年 7 月 22 日
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
回答 (1 件)
Jonas
2021 年 7 月 22 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Scatter Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!