Borrar filtros
Borrar filtros

Bar graph with unequal values.

1 visualización (últimos 30 días)
Alexander Guillen
Alexander Guillen el 7 de Sept. de 2023
Comentada: Alexander Guillen el 7 de Sept. de 2023
This is my code
clear all; close all; clc
a1 = [2 3 4 5 6];
a2 = 5;
b1 = [0.2 0.2 0.2 0.2 0.2];
b2 = 35;
bar(a1,b1)
hold on
bar(a2,b2)
At x = 5 ,the bar graph shows up as continous. Is there a way to to avoid this? I think this can be done by stacked but I am unsure.

Respuesta aceptada

Adam Danz
Adam Danz el 7 de Sept. de 2023
Editada: Adam Danz el 7 de Sept. de 2023
Are you expecting to see a stacked bar plot?
a1 = [2 3 4 5 6];
b1 = [0.2 0.2 0.2 0.2 0.2];
b2 = [nan nan nan 35 nan];
bar(a1,[b1;b2],'stacked')
Or are you expecting to see two axes?
figure()
tiledlayout(2,1)
a1 = [2 3 4 5 6];
a2 = 5;
b1 = [0.2 0.2 0.2 0.2 0.2];
b2 = 35;
ax1 = nexttile();
bar(a1,b1)
ax2 = nexttile();
bar(a2,b2)
linkaxes([ax1,ax2],'x')
  1 comentario
Alexander Guillen
Alexander Guillen el 7 de Sept. de 2023
Yes that is what I am looking for. Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB 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