Plot wont show line

17 visualizaciones (últimos 30 días)
Devin Downs
Devin Downs el 2 de Nov. de 2019
Respondida: Subhadeep Koley el 5 de Nov. de 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 comentario
KALYAN ACHARJYA
KALYAN ACHARJYA el 2 de Nov. de 2019
Please do share the complete code?

Iniciar sesión para comentar.

Respuestas (1)

Subhadeep Koley
Subhadeep Koley el 5 de Nov. de 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!

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by