Avoid overlapping different graphs that are placed in the same positions

3 ビュー (過去 30 日間)
Norma
Norma 2024 年 5 月 9 日
コメント済み: Kevin Holly 2024 年 5 月 9 日
Hello, I'm currently trying to plot two graphs in App Designer at the same position. They keep overlapping themselves and I'm not sure how to fix this issue. When I do "hold on" and "hold off", it opens another window where the graphs are shown. Is there any way to acheive this?
  2 件のコメント
Adam Danz
Adam Danz 2024 年 5 月 9 日
A screenshot might be helpful to understand the problem.
Norma
Norma 2024 年 5 月 9 日
This is example code. I'm unable to send a screenshot. I did two graphs like this in the same position.
lat = [48.915 48.907 48.901 48.893 48.887 48.881 48.875 48.869 48.865];
lon = [10.192 10.188 10.182 10.171 10.166 10.165 10.167 10.173 10.184];
gx = axes(app.FlightDataAppUIFigure);
Plot_XY_Data(lat, lon, gx);
function Plot_XY_Data(lat, lon, gx)
set(gx, 'position', [0.55 0.59 0.3 0.3]);
plot(gx,lat, lon, 'r--');
end

サインインしてコメントする。

回答 (1 件)

Kevin Holly
Kevin Holly 2024 年 5 月 9 日
You need to specify the axes you want to hold. By default, the hold command target the current axes that can be called with gca.
hold(app.UIAxes,"on")
  2 件のコメント
Norma
Norma 2024 年 5 月 9 日
I'm using geoaxes and stored it in a variable named gx. The texts for the graphs still overlap even though the graph itself isn't overlapping.
Kevin Holly
Kevin Holly 2024 年 5 月 9 日
What do you mean by the "texts for the graphs still overlap"? I'm not sure if I understand with the code you provided. Are you just trying to add another plot line as shown below?
lat = [48.915 48.907 48.901 48.893 48.887 48.881 48.875 48.869 48.865];
lon = [10.192 10.188 10.182 10.171 10.166 10.165 10.167 10.173 10.184];
fig = uifigure; % I changed this to uifigure for testing purposes.
gx = axes(fig);
Plot_XY_Data(lat, lon, gx);
% Add second plot
hold(gx,"on")
lon = lon + 0.05;
Plot_XY_Data(lat, lon, gx);
function Plot_XY_Data(lat, lon, gx)
set(gx, 'position', [0.55 0.59 0.3 0.3]);
plot(gx,lat, lon, 'r--');
end

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by