MATLAB: Plot range of values as bars

barrangeshaded plot

I'm trying to figure out how to plot a range of y values as bars. For example if my x-axis is days of the month, my bars would represent the range between the max and min temperatures for that day. The bar would be the shaded portion between the min and max values for each day. Kind of like a boxplot without all the statistical information included. Can't figure out how to do this. Any suggestions?

Best Answer

One approach:
Tmax = randi([25 30], 1, 10); % Create Data


Tmin = randi([15 20], 1, 10); % Create Data
days = 1:10; % Create Data
figure
plot([days; days], [Tmin; Tmax], 'LineWidth',5)
xlabel('Day')
ylabel('Temperature Range (°C)')
ylim([10 40])
xlim([0 11])
grid
Experiment to get the result you want.