plot 2 curves together and limit their own x axes

1 view (last 30 days)
Hello to everyone!
I am trying to put together the following two graphs:
1.- July
2.-August
But while doing it, I get the following part of the second graph-august- (the decreasing part when x>17000) that I dont want to show...
How can I limit the ploting axes of the second graph?
My code is the following:
%% Fit: 'Jul 2015 Supply France Peak'.
[xData, yData] = prepareCurveData( x_jul_15_s, Price_jul_15_s );
% Set up fittype and options.
ft = fittype( 'smoothingspline' );
excludedPoints = excludedata( xData, yData, 'Indices', 274 );
opts = fitoptions( 'Method', 'SmoothingSpline' );
opts.SmoothingParam = 3.69528725304706e-07;
opts.Exclude = excludedPoints;
% Fit model to data.
[fitresult{2}, gof(2)] = fit( xData, yData, ft, opts );
% Plot fit with data.
figure( 'Name', 'Jul 2015 Supply France Peak' );
%hold on
plot( fitresult{2},'m' );
% Label axes
xlabel( 'Volume [MWh]', 'Interpreter', 'none' );
ylabel( 'Price', 'Interpreter', 'none' );
grid on
curtick = get(gca, 'XTick');
set(gca, 'XTickLabel', cellstr(num2str(curtick(:))));
hold on
%%'Jul 2015 Supply France Peak'.
x = [12160 ];
y = [ 40.38];
scatter(x,y,'m')
%% Fit: 'Aug 2015 Supply France Peak'.
[xData, yData] = prepareCurveData( x_aug_15_s, Price_aug_15_s );
% Set up fittype and options.
ft = fittype( 'smoothingspline' );
excludedPoints = excludedata( xData, yData, 'Indices', [2 310 311] );
opts = fitoptions( 'Method', 'SmoothingSpline' );
opts.SmoothingParam = 3.69528725304706e-07;
opts.Exclude = excludedPoints;
% Fit model to data.
[fitresult{2}, gof(2)] = fit( xData, yData, ft, opts );
% Plot fit with data.
%figure( 'Name', 'Aug 2015 Supply France Peak' );
hold on
plot( fitresult{2},'b--');
% Label axes
xlabel( 'Volume [MWh]', 'Interpreter', 'none' );
ylabel( 'Price', 'Interpreter', 'none' );
grid on
curtick = get(gca, 'XTick');
set(gca, 'XTickLabel', cellstr(num2str(curtick(:))));
hold on
%%'Aug 2015 Supply France Peak'.
x = [11350 ];
y = [ 32.88];
scatter(x,y,'b','filled')
hold off
legend({'fitted curve July 2015','eq. July 2015','fitted curve Aug 2015','eq. Aug 2015'},'Location','northwest','NumColumns',2)
ylim([-500 3000])
Thanks in advance!
Angela

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by