Plot wont show line

2 次查看(过去 30 天)
Devin Downs
Devin Downs 2019-11-2
Im trying to plot these lines and it is just showing the point but not the lines for the plot any thoughts here is the code.
%output the Revenue and Total Cost plot
figure('color','w');
plot(y,Tcost,'r--','linewidth',3) ;
hold on
plot(y,revenue_cost_wpy,'linewidth',3) ;
hold on
plot(breakeven,'o k','Markerfacecolor','k');
grid on
title('Revenue and Total Cost')
xlabel('Number of Years (Y)')
ylabel('Revenue and Cost [$]')
%plot profit plot
figure('color','w')
plot(y, profit,'g-.','linewidth',2.5);
hold on
plot(breakeven,profit,'o k','Markerfacecolor','k')
grid on
title('Profit')
xlabel('Number of Years (Y)')
ylabel('Profit of the construction choice [$]')
legend('Profit','location','northwest')

回答(1 个)

Subhadeep Koley
Subhadeep Koley 2019-11-5
Hi, it is difficult to provide an exact solution without your original data. However, when I executed your code with demo data, it is giving output as expected.
close all;clc;clear;
% Example data for test
y = 1:100;
Tcost = linspace(10,80,100);
revenue_cost_wpy = linspace(0,100,100);
profit = revenue_cost_wpy - Tcost;
breakeven = 32;
% Plotting
figure('color','w');
plot(y,Tcost,'r--','linewidth',3) ;
hold all;
plot(y,revenue_cost_wpy,'linewidth',3) ;
plot(y,breakeven,'o k','Markerfacecolor','k');
grid on;
title('Revenue and Total Cost');
xlabel('Number of Years (Y)');
ylabel('Revenue and Cost [$]');
legend({'Total Cost','Revenue','Breakeven'},'location','northwest');
figure('color','w');
plot(y, profit,'g-.','linewidth',2.5);
hold on;
plot(breakeven,profit,'o k','Markerfacecolor','k');
grid on;
title('Profit');
xlabel('Number of Years (Y)');
ylabel('Profit of the construction choice [$]');
legend('Profit','location','northwest');
hold off;
rev1.png rev2.png
Check whether these kind of output is expected or not.
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by