Create a sideways filled in bar plot
Mostrar comentarios más antiguos
I want to create a figure that looks alike the attached, where I have a bar and when the value is 1, it is filled in blue, and when the value is 0 it has no colour.
The x axis must be datetime values and the bars must have filled colour, i.e. they cannot be outlines
Is this possible to do on MATLAB?
Respuestas (2)
David Hill
el 4 de Mayo de 2020
0 votos
Yes, see bar() function
2 comentarios
William Garrett
el 4 de Mayo de 2020
David Hill
el 4 de Mayo de 2020
Look at barh() function and see if you can figure it out.
Star Strider
el 4 de Mayo de 2020
It would help to have an example of your data.
That aside, the sort of plot you want to do is straightforward.
Try this:
v = sort(rand(1,20)); % Create Vecttor Of Independent Variable Values
figure
yv = [0 0 1 1];
hold on
for k = 1:2:numel(v)-1
patch([v(k:k+1) fliplr(v(k:k+1))], yv, 'b')
end
hold off
It would likely be relatively straightforward to adapt this to a datetime vector.

Categorías
Más información sobre Discrete Data Plots en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!