(App Designer/geoplot ) How can I plot multiple outputs on the same graph from the same function?

7 views (last 30 days)
I want to plot multiple points with Input values. What I have is to take in the user inputs ( variable are northing and easting )
conversion is a function that takes in 2 arguments and give out the latitude and longitude that are used by geoscatter.
What i want to do is to take in another set of user inputs and still display the longitude and latidude of both plots. There is only one graph to be shown in the interface. The problem i am facing is when I click the plot button again, my previous plot disappear and my new plot is shown. I want to show both values.
I have tried checkbox, if i checked it, I want to store the values and still plot it. Is there a way to store the values everytime i click plot?
northing = str2double(app.NorthingEditField.Value);
easting = str2double(app.EastingEditField.Value);
% conversion(easting,northing) arrangement;
testdata= [easting,northing];
[testdatax,testdatay]= conversion(testdata(1),testdata(2)) ;
gx = geoaxes(app.Panel);
app.plotdata = geoscatter(gx,testdatax,testdatay,'ro','filled');
geolimits([1.345 1.35],[103.6 104.04])
geobasemap(gx,"streets")
hold on
% if app.CheckBox.Value
% testdata1= [easting,northing];
% [testdatax1,testdatay1]= EN2LatLon(testdata1(1),testdata1(2)) ;
% gx = geoaxes(app.Panel);
% app.plotdata = geoscatter(gx,testdatax1,testdatay1,'blue','filled');
% geolimits([1.345 1.35],[103.6 104.04]) ;
% geobasemap(gx,"streets");
% end

Answers (1)

Anshika Chourasia
Anshika Chourasia on 28 Dec 2021
Hi,
“hold” function is useful for retaining current plot when adding new plots. Instead of using hold on command, specify the geoaxes as an input argument to the “hold” function to resolve the issue.
Please refer this link for more information on specifying hold state for a particular axis.
  2 Comments
thin su
thin su on 1 Jan 2022
hi
I understand. I have tried that as well. I have only one geoaxes but everytime i put a new input, my map still plot a new point and cancels the previous point. This is the code i wrote with hold statement.
hold(gx,"on") ;
This is what my interface looks like.What i wanted to do is to get my input, hold that plotting and plot my other points as well. When i click 'clear', i will delete all the plots to clear the map.
Anshika Chourasia
Anshika Chourasia on 7 Jan 2022
One possible workaround could be to use global vectors for storing northing-easting values and every time "Plot" button is pressed append the current northing/easting values to the respective global vector. In this way previous values will be retained along with newer values in the vectors, and then plot them using "geoplot" with all the avaliable data entries. Following links may prove helpful to understand the procedure in detail:
  1. Creating, Concatenating, and Expanding Matrices
  2. Plot line in geographic coordinates

Sign in to comment.

Categories

Find more on Geographic Plots in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!