How to position a geoaxes figure within a uifigure (2024)

16 Ansichten (letzte 30 Tage)

Ältere Kommentare anzeigen

Bradley am 21 Mär. 2024

  • Verknüpfen

    Direkter Link zu dieser Frage

    https://de.mathworks.com/matlabcentral/answers/2097401-how-to-position-a-geoaxes-figure-within-a-uifigure

  • Verknüpfen

    Direkter Link zu dieser Frage

    https://de.mathworks.com/matlabcentral/answers/2097401-how-to-position-a-geoaxes-figure-within-a-uifigure

Beantwortet: Voss am 3 Apr. 2024

In MATLAB Online öffnen

Hi again everyone,

My learning curve has been steep and im getting frustrated. Maybe its time for a break but before that I want to ask another question.

Im trying to progammatically create a GUI for a processing program im building, I have a script that does everything I want and looks ok but a GUI would be way more helpful, also I dont really want to use the app builder. I think doing it the hard way will help me learn more. Just to start ive read through the documentation extensivly and tried many different options with no luck. I created a function with a few nested functions, when I set up my options and click 'run' I want a world map to show up with all my data plotted on it. Right now I can generate this map with no problem, however it fills the entire GUI, I want to position this figure so it shows up in the bottom left corner of the uifigure. I have other plots that are created that I want to include in the uifigure as well. Right now when I set my options and click run everything pops up as its own figure.

My code below is for the world map, first it concatenates all the lat and long data from each file and plots them so you can see each survey your processing, afterward it plots a surface map for each with depth included. The block of code I have posted here is just to plot the figure, it plots fine like I mentioned but fills the entire uifigure, how do I resize and position this where I want? I have tried a lot of different combinations, when I include gx.Position the map doesnt show up at all. Any help and advise is appreciated. Thank you.

gx = geoaxes;

gx.Parent = (fig);

gx.Position = [100 100 500 500];

geoplot(gx,FinalLat, FinalLong, 'r-*')

geobasemap(gx,'grayterrain')

1 Kommentar

-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Anton Kogios am 22 Mär. 2024

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/2097401-how-to-position-a-geoaxes-figure-within-a-uifigure#comment_3106436

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/2097401-how-to-position-a-geoaxes-figure-within-a-uifigure#comment_3106436

In MATLAB Online öffnen

Hi Bradley, I'd love to help out - could you send your whole code so I can recreate your problem please?

Something you can try is

gx = geoaxes(fig);

This removes the need for your 'gx.Parent = (fig)' line.

Also, MATLAB App Designer is surprisingly really easy to learn and start using. Would recommend.

Melden Sie sich an, um zu kommentieren.

Melden Sie sich an, um diese Frage zu beantworten.

Antworten (2)

Avni Agrawal am 3 Apr. 2024

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/2097401-how-to-position-a-geoaxes-figure-within-a-uifigure#answer_1435476

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/2097401-how-to-position-a-geoaxes-figure-within-a-uifigure#answer_1435476

In MATLAB Online öffnen

Hi @Bradley, I understand that you are trying to position a 'geoaxes' object within a specific area of a 'uifigure'. The key here is to ensure that the 'geoaxes' is a child of the 'uifigure' (or a container within the uifigure), and then to correctly set the 'Position' property.

However, there's a mistake in how you're setting the 'Position' property. The 'Position' property expects values in the format [x y width height], where x and y specify the distance from the left and bottom edges of the parent container, respectively, and 'width' and 'height' specify the size of the component. All values are in pixels.

Given that, your code should look something like this:

% Assuming 'fig' is your uifigure

fig = uifigure('Name', 'My GUI', 'Position', [100, 100, 800, 600]);

% Create geoaxes as a child of the uifigure

gx = geoaxes('Parent', fig);

% Set the position of the geoaxes within the uifigure

% Here, [x y width height] sets the geoaxes to be at the bottom left

% with a width of 500 pixels and a height of 500 pixels.

gx.Position = [10 10 500 500]; % Adjust [x y width height] as needed

% Now plot on the geoaxes

geoplot(gx, FinalLat, FinalLong, 'r-*');

geobasemap(gx, 'grayterrain');

A few key points to remember:

  • Ensure fig is your uifigure object.
  • When setting gx.Parent = fig, you're specifying that the geoaxes is a child of the uifigure, which is correct.
  • Adjust the gx.Position values to position the map exactly where you want it within the uifigure. The first two numbers [10 10] are the bottom-left corner relative to the uifigure, and the last two numbers [500 500] are the size of the geoaxes.
  • If you're placing multiple components within the uifigure, consider using uigridlayout or uiflowcontainer for more flexible and automatic layout management
  • Remember to adjust the Position values to fit the layout you're aiming for.

Please refer to below mentioned documentations link for better understanding:

  1. uifigure Documentation: https://www.mathworks.com/help/matlab/ref/uifigure.html
  2. geoaxes Documentation: https://www.mathworks.com/help/matlab/ref/geoaxes.html
  3. Position Property for UI Components: Here's an example within the uicontrol documentation that explains the Position property: https://www.mathworks.com/help/matlab/ref/uicontrol.html

I hope this helps.

0 Kommentare

-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Voss am 3 Apr. 2024

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/2097401-how-to-position-a-geoaxes-figure-within-a-uifigure#answer_1435506

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/2097401-how-to-position-a-geoaxes-figure-within-a-uifigure#answer_1435506

In MATLAB Online öffnen

Default geoaxes Units are normalized (see here), which means that a Position of [100 100 500 500] places the geoaxes' lower left corner at 100 times the size of the uifigure and makes the geoaxes' size 500 times the size of the uifigure. That's why it doesn't show up when specifying the Position - it's way outside the uifigure.

To make the Position [100 100 500 500] pixels, set its Units to pixels before setting the position, e.g.:

gx = geoaxes('Parent',fig,'Units','pixels','Position',[100 100 500 500]);

It doesn't need to be in one call like that, but Units does need to be set before Position for it to work right.

(If you want the geoaxes to remain at the size 500x500 pixels, you'll also need to specify that the uifigure has its 'AutoResizeChildren' property set to 'off', if you are not already doing that.)

0 Kommentare

-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Melden Sie sich an, um diese Frage zu beantworten.

Siehe auch

Kategorien

MATLABApp BuildingDevelop Apps ProgrammaticallyDevelop uifigure-Based Apps

Mehr zu Develop uifigure-Based Apps finden Sie in Help Center und File Exchange

Tags

  • uifigure

Produkte

  • MATLAB

Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Es ist ein Fehler aufgetreten

Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.


Translated by How to position a geoaxes figure within a uifigure (5)

How to position a geoaxes figure within a uifigure (6)

Website auswählen

Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .

Sie können auch eine Website aus der folgenden Liste auswählen:

Amerika

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europa

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asien-Pazifik

Kontakt zu Ihrer lokalen Niederlassung

How to position a geoaxes figure within a uifigure (2024)

References

Top Articles
Latest Posts
Article information

Author: Horacio Brakus JD

Last Updated:

Views: 5756

Rating: 4 / 5 (71 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Horacio Brakus JD

Birthday: 1999-08-21

Address: Apt. 524 43384 Minnie Prairie, South Edda, MA 62804

Phone: +5931039998219

Job: Sales Strategist

Hobby: Sculling, Kitesurfing, Orienteering, Painting, Computer programming, Creative writing, Scuba diving

Introduction: My name is Horacio Brakus JD, I am a lively, splendid, jolly, vivacious, vast, cheerful, agreeable person who loves writing and wants to share my knowledge and understanding with you.