Plot wont show line

1 回表示 (過去 30 日間)
Devin Downs
Devin Downs 2019 年 11 月 2 日
回答済み: Subhadeep Koley 2019 年 11 月 5 日
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 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 11 月 2 日
Please do share the complete code?

サインインしてコメントする。

回答 (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 Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by