Plotting table into bar graph

41 visualizaciones (últimos 30 días)
anouar atmn
anouar atmn el 8 de Abr. de 2021
Editada: Cris LaPierre el 8 de Abr. de 2021
Hi, I got a question.
I got a table that has a format of 1x29, as seen bellow:
The table goes on till H14G (1x29)
Im trying to make a bar graph from this table, but im unable to make it work. I need the bar graph sectioned as seen bellow.
I'm only able to make data stack as seen bellow:
hold on
bar (ElektriciteitsTableYearly.H01G_kWh);
hold off
bar (ElektriciteitsTableYearly.H01U_kWh);
legend ({'H01U','H01G'});

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 8 de Abr. de 2021
Editada: Cris LaPierre el 8 de Abr. de 2021
The bar chart you show has 3 groups of 2. I'm not seeing how you want to create groups with your data.
Perhaps start by just creating a bar for each column?
bar(ElektriciteitsTableYearly{:,2:end})
See here for more.
  3 comentarios
Cris LaPierre
Cris LaPierre el 8 de Abr. de 2021
Editada: Cris LaPierre el 8 de Abr. de 2021
As you can see in the link I shared, the data must be arranged in matrix to greate a grouped bar chart. Each row corresponds to a group.
Try something like this.
bar(reshape(ElektriciteitsTableYearly{:,2:end},2,[])')
If that doesn't work, consider sharing your data. Save your table to a mat file and attach it using the paperclip icon.
anouar atmn
anouar atmn el 8 de Abr. de 2021
Thank you again! This is exactly what i needed!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects 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