How to draw line graph with same values in this bar graph?
1 view (last 30 days)
Show older comments
x = [1 2 3 4 5 6 7];
temp_high = [149.1350 143.9020 19.1230 19.0350 11.8150 19.8610 11.6600];
w1 = 0.5;
bar(x,temp_high,w1,'FaceColor',[0 0 1])
temp_low =[29.8270 28.7804 3.8246 3.8070 2.3630 3.9722 2.3320];
w2 = .25;
hold on
bar(x,temp_low,w2,'FaceColor',[1 0 0])
hold off
grid on
ylabel('Cost Incurred')
legend({'Units of gas consumed','cost incurred'},'Location','northwest')
ax = gca;
ax.XTick = [1 2 3 4 5 6 7];
ax.XTickLabels = {'Adding item to chain','Purchasing item from list','Shipment of item','Receiving item','Checking balance in user account','Fetching of item status','Total item count calculation'};
ax.XTickLabelRotation = 45;
0 Comments
Accepted Answer
VBBV
on 28 Nov 2020
clear
x = [1 2 3 4 5 6 7];
temp_high = [149.1350 143.9020 19.1230 19.0350 11.8150 19.8610 11.6600];
w1 = 0.5;
bar(x,temp_high,w1,'FaceColor',[0 0 1])
temp_low =[29.8270 28.7804 3.8246 3.8070 2.3630 3.9722 2.3320];
w2 = .25;
hold on
bar(x,temp_low,w2,'FaceColor',[1 0 0])
hold on
plot(x,temp_high,'b-','linewidth',2)
hold on
plot(x,temp_low,'r-','linewidth',2)
grid on
ylabel('Cost Incurred')
legend('Units of gas consumed','cost incurred','Units of gas consumed','cost incurred','Location','northwest')
ax = gca;
ax.XTick = [1 2 3 4 5 6 7];
ax.XTickLabels = {'Adding item to chain','Purchasing item from list','Shipment of item','Receiving item','Checking balance in user account','Fetching of item status','Total item count calculation'};
xtickangle(45)
3 Comments
VBBV
on 28 Nov 2020
clear
x = [1 2 3 4 5 6 7];
temp_high = [149.1350 143.9020 19.1230 19.0350 11.8150 19.8610 11.6600];
w1 = 0.5;
temp_low =[29.8270 28.7804 3.8246 3.8070 2.3630 3.9722 2.3320];
w2 = .25;
plot(x,temp_high,'b-','linewidth',2)
hold on
plot(x,temp_low,'r-','linewidth',2)
grid on
ylabel('Cost Incurred')
legend('Units of gas consumed','cost incurred','Location','northwest')
ax = gca;
ax.XTick = [1 2 3 4 5 6 7];
ax.XTickLabels = {'Adding item to chain','Purchasing item from list','Shipment of item','Receiving item','Checking balance in user account','Fetching of item status','Total item count calculation'};
xtickangle(45)
More Answers (1)
Ameer Hamza
on 28 Nov 2020
Edited: Ameer Hamza
on 28 Nov 2020
Are you looking for something like this
x = [1 2 3 4 5 6 7];
temp_high = [149.1350 143.9020 19.1230 19.0350 11.8150 19.8610 11.6600];
w1 = 0.5;
bar(x,temp_high,w1,'FaceColor',[0 0 1])
hold on
plot(x,temp_high, 'LineWidth', 2)
temp_low =[29.8270 28.7804 3.8246 3.8070 2.3630 3.9722 2.3320];
w2 = .25;
bar(x,temp_low,w2,'FaceColor',[1 0 0])
plot(x,temp_low, 'LineWidth', 2)
hold off
grid on
ylabel('Cost Incurred')
legend({'Units of gas consumed','cost incurred'},'Location','northwest')
ax = gca;
ax.XTick = [1 2 3 4 5 6 7];
ax.XTickLabels = {'Adding item to chain','Purchasing item from list','Shipment of item','Receiving item','Checking balance in user account','Fetching of item status','Total item count calculation'};
ax.XTickLabelRotation = 45;
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!