How do I plot a circle on a Matlab figure?
16 次查看(过去 30 天)
显示 更早的评论
I want to plot a circle with blinking effect on a Matlab figure. I want this marker on the simulation to have a blinking effect everytime my readings are above threshold value. Is there any function or way to achieve this?
So far I have tried:
Using this creates a separate figure, which I don't want:
plot(0,0,'ro','MarkerSize',10,'MarkerFaceColor','r','MarkerEdgeColor','r');
I want to create a plot on the figure which is created by this code:
viewer = trackingGlobeViewer('Basemap','streets-dark',...
'TrackLabelScale',1.3,'TrackHistoryDepth',4000,...
'CoverageMode','Coverage');
For instance I want to plot a marker at the bottom right of this figure generated by the above code.
EDIT:
Thank you!
0 个评论
回答(2 个)
Gael Goron
2023-2-1
Hi,
The trackingGlobeViewer is based on the same technology as geoglobe from the Mapping Toolbox. Globe based visualizations are not like the usual MATLAB graphics plots, you cannot use 'plot' to overlay graphics on top of a globe.
First create the trackingGlobeViewer as in the example:
viewer = trackingGlobeViewer('Basemap','streets-dark',...
'TrackLabelScale',1.3,'TrackHistoryDepth',4000,...
'CoverageMode','Coverage');
To retrieve the geoglobe object you can use either one of the following lines of code:
globe = findall(groot, 'type', 'globe');
globe = viewer.Globe; %Undocumented
% Next plot markers with geoplot3
% geoplot3(globe, ...)
2 个评论
Gael Goron
2023-2-2
Yes you can plot a marker with geoplot3, it would look like this for instance (see the documentation link from my previous post for more details).
geoplot3(globe, 71,-42,10,'Color','r','MarkerSize',13,'Marker','o');
Note that by default, the geoplot3 command will move the globe camera to the location of the markers. If you do not want this behavior, you can disable it by setting the camera modes to manual like this:
% Disable camera first
campitch(globe,'manual')
camroll(globe,'manual')
camheading(globe,'manual')
campos(globe,'manual')
camheight(globe,'manual')
% Plot marker
geoplot3(globe, 71,-42,10,'Color','r','MarkerSize',13,'Marker','o');
The marker will stay at this particular location on the globe, because the default option for NextPlot is 'add'. If you need to clear the marker, you can set NextPlot to 'replace'.
There is currently no capability to display text on the globe, but I can pass along this information to the Mapping Toolbox team.
Walter Roberson
2023-1-23
plot(0,0,'ro','MarkerSize',10,'MarkerFaceColor','r','MarkerEdgeColor','r');
That could have several different effects.
- If you have no figures of any kind opened, or if you do have figures open but none of them are the "current" figure, then a new traditional figure would be opened and a new axes placed in the new traditional figure, and the marker would be plotted in that axes
- If you have uifigure() open but not traditional figures, then by default the handle visibility is set off for uifigure() so plot() would not be able to locate the uifigure as being the current figure; this then becomes the same as the above where a new traditional figure is created
- if you have a "current" (visible) figure that has no "current" axes, then a new axes would be created in the figure and the marker would be plotted in the new axes
- if you have a "current" (visible) axes whose "NextPlot" property is set to "replace" (the default if you have not used "hold on") then the axes will be cla() but not cla('reset') -- the plot of the marker would replace the current plot
- if you have a "current" (visible) axes whose "NextPlot" is not "replace" then the plot of the marker would be added at layer z = 0 without removing any current drawing
These days the most common reason that a plot() creates a new figure is if you are using App Designer: when you use App Designer you should always tell plot() explicitly which existing axes you want to draw into (because the handle visibility of the UIAxes will be off and plot() will not be able to find the axes when it does gca() )
14 个评论
Walter Roberson
2023-1-24
I do not know; I would need to poke around the internals more, but I do not have that toolbox.
Perhaps it is time to consider using annotation . Annotations live in a transparent graphics pane above all of the other panes (so they should always be on top.) Because they do not live inside axes, the position coordinates for annotation default to being normalized relative to the figure . You can change the units, but you cannot change the units to data coordinates
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Geographic Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!