Why is there extra data in my graph?

1 view (last 30 days)
Matías
Matías on 21 Nov 2022
Edited: VBBV on 21 Nov 2022
Basically, I have this code.
fig = groupsummary(eventsTOP,"Event_Type","none")
x =fig.Event_Type; y = fig.GroupCount;
bar(x,y)
Where "fig" is a table that I extract from a larger table ("eventsTOP") that is already filtered with the data I want.
The table "fig" has the following data:
Event_Type GroupCount
_________________ __________
Coastal Flood 5
Drought 38
Flash Flood 212
Flood 34
Frost/Freeze 16
Funnel Cloud 4
Hail 35
Heat 30
Heavy Rain 7
High Wind 10
Hurricane 9
Lightning 4
Storm Surge/Tide 14
Strong Wind 4
Thunderstorm Wind 88
Tornado 35
Tropical Storm 48
Wildfire 1
As you can see there are 18 Event_Type, but when it comes to plotting it, this happens.
I have more data than I really want to use, and I don't understand where it comes from if I'm using the fig table as a reference.
I just want to use the 18 data I have.

Answers (1)

VBBV
VBBV on 21 Nov 2022
x =fig.eventsTOP.Event_Type; y = fig.eventsTOP.GroupCount; %
bar(x,y)
  2 Comments
VBBV
VBBV on 21 Nov 2022
check the above, may be you need to access the table eventsTOP first and then its variables Event_Type and GroupCount
VBBV
VBBV on 21 Nov 2022
Edited: VBBV on 21 Nov 2022
or use this option
fig = groupsummary(eventsTOP,["Event_Type","GroupCount"],"none","IncludeEmptyGroups",false) %use this option
x =fig.Event_Type; y = fig.GroupCount;
bar(x,y)

Sign in to comment.

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!