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?
0 个评论
采纳的回答
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 个评论
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:
- 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.
- 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 Center 和 File Exchange 中查找有关 Geographic Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!