MATLAB Answers

How to import axesm into app designer?

10 ビュー (過去 30 日間)
abblah abblah
abblah abblah 2020 年 3 月 17 日
コメント済み: Adam Danz 2020 年 4 月 5 日
Hi,
I am developing a GUI using app designer. This contains multiple UIAxeses.
One of these UIAxeses is going to show site location in map using meshm and plotm functions. How can I convert an existing UIAxes to a map axes? or how can I import a map axes into the app designer?
unfortunately the axesm and worldmap functions open a new figure including a map axes which is not sutible for a standalone application. I have spent a large time for searching with no specific solution :(((

  0 件のコメント

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

採用された回答

abblah abblah
abblah abblah 2020 年 4 月 5 日
To import a map axes, it is only sufficient to change the parent of a map axes as follows:
% ... MapAxes is created in a new figure
% Change the Parent of the map axes
TempParent = MapAxes.Parent;
MapAxes.Parent = UIAxes.Parent;
% fit the size
MapAxes.Units = 'pixel';
MapAxes.Position = UIAxes.Position;
% delete the initial temperory UIAxes
delete(UIAxes);
% delete the temperory map figure
delete(TempParent);

  1 件のコメント

Adam Danz
Adam Danz 2020 年 4 月 5 日
Note some potential problems with this answer:
When you delete app.UIAxes at the end, that handle will be empty and you will not have access to the new axes handle unless you store is as a property of the app. I also recommend changing the units and position properties before changing the parent property. Another improvement would be to create the external figure with visibility off.

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

その他の回答 (1 件)

Adam Danz
Adam Danz 2020 年 3 月 17 日
編集済み: Adam Danz 2020 年 3 月 19 日
"...or how can I import a map axes into the app designer?"
You can copy the content of a map axis to a UI Axis. Here's a demo.
% Create map in external figure
korea = load('korea.mat');
Z = korea.map;
R = georasterref('RasterSize', size(Z), ...
'Latlim', [30 45], 'Lonlim', [115 135]);
worldmap(Z, R)
meshm(Z, R)
ax = gca();
% Create UIAxes and copy content
uif = uifigure();
uiax = uiaxes(uif);
copyobj(ax.Children, uiax)
uiax.Visible ='off';

  2 件のコメント

abblah abblah
abblah abblah 2020 年 4 月 5 日
This is not correct, since the modified axes is not yet a map axes, In other words you have not imported the map axes, you have only copied the map axes's children.
This method bug is revealed in the new plot which you are faced with the error "the current axes is not a map axes".
Adam Danz
Adam Danz 2020 年 4 月 5 日
"This is not correct, ... you have not imported the map axes, you have only copied the map axes's children."
@abblah abblah, that's exactly what the description indicates at the top of my answer. In this answer, the app's axes are used to host the map content instead of replacing the axes.

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

Community Treasure Hunt

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

Start Hunting!

Translated by