Borrar filtros
Borrar filtros

Is it possible to add text to geobubble plots?

12 visualizaciones (últimos 30 días)
John R
John R el 21 de Jul. de 2020
Comentada: Johannes Reimer el 1 de Feb. de 2022
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?

Respuesta aceptada

Kiran Felix Robert
Kiran Felix Robert el 24 de Jul. de 2020
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 comentarios
John R
John R el 24 de Jul. de 2020
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 el 1 de Feb. de 2022
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Geographic Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by