How to draw line graph with same values in this bar graph?

3 Ansichten (letzte 30 Tage)
soujanya duvvi
soujanya duvvi am 28 Nov. 2020
Kommentiert: soujanya duvvi am 28 Nov. 2020
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;

Akzeptierte Antwort

VBBV
VBBV am 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 Kommentare
VBBV
VBBV am 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)
soujanya duvvi
soujanya duvvi am 28 Nov. 2020
Thanx a ton i was exactly trying for this only

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Ameer Hamza
Ameer Hamza am 28 Nov. 2020
Bearbeitet: Ameer Hamza am 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;
  1 Kommentar
soujanya duvvi
soujanya duvvi am 28 Nov. 2020
Yes i want only the line graph i dont want the bar plot in it. Can i just retain the line plot and remove the bar plot?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by