Is it possible to add text to geobubble plots?

10 次查看(过去 30 天)
I get this error when I try to add text to a geobubble plot:
Text cannot be a child of GeographicBubbleChart.
Is there any way to add text?

采纳的回答

Kiran Felix Robert
Kiran Felix Robert 2020-7-24
Hi John,
It is my understanding that you want to add text to the geobubble plot at a given position. This can be done using the uicontrols function provided you have the figure handle. One possible way to do this is as shown here, assuming you want to add a text ‘Text’ at [150.,150], as shown below (the table data is obtained from the example shown here)
h = figure('Name','GeoBubbleFig');
g = geobubble(h,tsunamis,'Latitude','Longitude'...
,'SizeVariable','MaxHeight','ColorVariable','Cause');
T = uicontrol(h,'Style','text','String','Text','Position',[150 150 50 20]);
Thanks,
Kiran
  2 个评论
John R
John R 2020-7-24
Thanks, is it possible using this function to use my lat and lon coordinates that were used to create the geobubble plot for the positioning of the text on the plot?
Johannes Reimer
Johannes Reimer 2022-2-1
I had the same problem and since it is not currently possible to use text with geobubble, i ended up using geoscatter:
h = figure('Name','Nice Bubble Plot');
g = geobubble(latiude,longitude,size,color,'MarkerFaceColor','flat');
text(latiude,longitude,name);
However, this solution comes with some downsides:
  1. To get the right size of the circles you have to fiddle around with the size variable (e. g. multiplying by 10). To show the size differences more clearly in my case, I used the squared size.
  2. The color isn't automatically chosen by the category. However, it can be defined as follows:
category = ['Category2','Category3','Category3','Category 1','Category2','Category3'] % And so on ...
categoryList = ['Category 1','Category2','Category3']; % List of possible categories
categoryColor = [ 0 0.619 0.878; % List of corresponding category colors
0.078 0.690 0.678;
0.415 0.690 0.137];
for i=1:size(latitude,2)
index(i) = find(strcmp(categoryList,category(i))); % Calculating the index of categoryColor for every element
end
% Substitute 'color' with 'categoryColor(index,:)' in the code snippet given above
% This will insert the corresponding RGB triplet for each element.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by