Plot with x-axis limits going from [180:360] then [0:180] contiguously
15 次查看(过去 30 天)
显示 更早的评论
Here is a sample plot of my data:
I've searched through the community looking for ideas but I may be struggling with how to search for this particular issue.
I've come across several cases that would solve my issue "visually" using "unwrap" or "wrapTo360", but these both would alter my data set.
I want to keep the integrity of my data, but I'd like to have my plot be contigous from 250 degrees at the origin to 360 degrees, then continue to 0 degrees to 250 degrees similar to the second sample plot. (I've set the summary to be 180:360 to aid others searching as those are typical angles and mine are more specific).
I would like to do this programmatically as I am able to do it manually, but I have thousands of these to run through.
2 个评论
the cyclist
2023-6-15
It's difficult to infer the fully general "rule" here, from just one example. Can you post two or three examples of the data? You can upload it using the paper clip icon in the INSERT section of the toolbar.
回答(2 个)
Les Beckham
2023-6-15
It seems extremely odd that your data would "wrap" at 250 degrees. Nevertheless...
elevation = [26:80 0:25];
azimuth = linspace(0, 360, numel(elevation));
delta_az = unique(diff(azimuth));
plot(azimuth, elevation, '.')
grid on
xlabel('Azimuth (deg)')
ylabel('Elevation (deg)')
idx = azimuth >= 250;
figure
offset = azimuth(find(azimuth <= 250, 1, 'last'));
plot([azimuth(idx) (azimuth(~idx) + 360 + delta_az)] - offset, [elevation(idx) elevation(~idx)], '.')
grid on
xticklabels(string([250:50:350 0:50:250]))
xlabel('Azimuth (deg)')
ylabel('Elevation (deg)')
0 个评论
the cyclist
2023-6-15
You only give one example, and this will do what you want for this one example. It does not touch your data, just what is plotted.
I am guessing this is not robust enough for your data in general. But, since you have not given us more examples, it is not possible to know how general this needs to be.
Maybe you can figure out the rest. (Also, I notice a couple rogue points. I did not inspect the reason for those.)
tbl = readtable("sampleData.xlsx");
figure
scatter(tbl.Var1 + 360*(tbl.Var1<250),tbl.Var2)
set(gca,"XTickLabel",[250:50:350 0:50:360])
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!