Is it possible to add text to geobubble plots?

조회 수: 11 (최근 30일)
John R
John R 2020년 7월 21일
댓글: Johannes Reimer 2022년 2월 1일
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에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by