changing the axis of a plot

x=[0:0.01:20]
y=max(x-10,0)-blsprice(10,10,0.02,0.2,0.2)
plot(x,y)
xlabel('Stock Price at Maturity ($)');
ylabel('Gain ($)');
axis([0 20 -2 10]);
set(gca,'Box','off')
The command above gives me the payoff of an call option, unfortunately the x-axis goes from -2 to 20, but I would like to see the x-axis from 0 to 20, so the starting point should be y=0 and not y=-2. However the plot should still show the y-axis from -2 to 10 and the negative values for y

Risposte (1)

Azzi Abdelmalek
Azzi Abdelmalek il 24 Mar 2013
xlim([0 20])
ylim([0 10])

5 Commenti

x=[0:0.01:20]
y=max(x-10,0)-blsprice(10,10,0.02,0.2,0.2)
plot(x,y)
xlabel('Stock Price at Maturity ($)');
ylabel('Gain ($)');
xlim([0 20])
ylim([0 10])
set(gca,'Box','off')
but that way, the y axis doesn't goes to -2, it stopps at 0 and although I want the x-axis to start at the point where x is zero and y is zero (and not y=-x and x=0) I also need to see the negative y values
ylim([-2 10])
Locks
Locks il 24 Mar 2013
that just gives me a single line, is that correct? I am not sure how I have to handle this code to combine it with mine, could you give me an example?

Accedi per commentare.

Tag

Richiesto:

il 24 Mar 2013

Community Treasure Hunt

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

Start Hunting!

Translated by