Plot wont show line

1 visualizzazione (ultimi 30 giorni)
Devin Downs
Devin Downs il 2 Nov 2019
Risposto: Subhadeep Koley il 5 Nov 2019
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 Commento
KALYAN ACHARJYA
KALYAN ACHARJYA il 2 Nov 2019
Please do share the complete code?

Accedi per commentare.

Risposte (1)

Subhadeep Koley
Subhadeep Koley il 5 Nov 2019
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!

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by