I can't show ColorVariable on geobubble

조회 수: 5 (최근 30일)
Gorkem Akgul
Gorkem Akgul 2021년 3월 26일
댓글: Gorkem Akgul 2021년 3월 26일
Hi,
I'm trying to do some stuffs on a covid dataset to improve my datascience skills. I have a talbe of 10 countries with the most active cases. I plot them with geoplot but it doesn't show the color variable or size variable. I've been trying to get on top of that problem for 5 days but still couldn't handle it. The thing that causes the problem may be the categories with count equals to 0.
I extract the 10 countries with most active cases but when i click Edit Categories on table i still see there are other categorical Countries but with 0 counts. Perhaps they affect the geobubble even though they have 0 counts(there are large number of categories like that). I don't want to delete them one by one, there must be a way to delete all categories with count equals zero.
Could somebody possibly help me please ?
  댓글 수: 3
Gorkem Akgul
Gorkem Akgul 2021년 3월 26일
Hi I'm using the following code.
alldatasummary2=alldatasummary2(2:end,:);
gb = geobubble(alldatasummary2,'Lat','Lon','SizeVariable','sum_Active','ColorVariable','Country','Title','Active Cases vs Country')
Gorkem Akgul
Gorkem Akgul 2021년 3월 26일
Well, I solved it :)
For thouse who have the same problem, Even though you deleted rows with some categories in your table the categories still do exist but you don't see them in your table due to the fact that they have no counts. In order to get rid of them using removecats wouldn't be a good solution i suppose if you have large number of categories ( in my case around 1000). Instead, i convert to Country to string so that i got rid of the categories with counts == 0 in the second picture. Then i convert it back to categorical so that i get the categories i just want.
alldatasummary2.Country=string(alldatasummary2.Country)
alldatasummary2.Country=categorical(alldatasummary2.Country)

댓글을 달려면 로그인하십시오.

답변 (1개)

Cris LaPierre
Cris LaPierre 2021년 3월 26일
Why is removecats not an option?
B = removecats(A) removes unused categories from the categorical array, A. The output categorical array, B, has the same size and values as A. However, B possibly has fewer categories.
All you need to do is
alldatasummary2.Country = removecats(alldatasummary2.Country);
  댓글 수: 2
Cris LaPierre
Cris LaPierre 2021년 3월 26일
편집: Cris LaPierre 2021년 3월 26일
For those curious why the categories still persist even if they don't appear in the list, this is due to the definition of a categorical variable.
  • categorical is a data type to store data with values from a finite set of discrete categories.
The categories can be viewed with the following:
  • C includes all categories in A, even if A does not contain any data from a category. To see the unique values in A, use unique(A).
Gorkem Akgul
Gorkem Akgul 2021년 3월 26일
Thank you for the answer

댓글을 달려면 로그인하십시오.

카테고리

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