numpy - Removing coloured axis markers from Python plot -
edit: enhance code example/upload improved picture
i using pylab plot graph in python (example code shown below). plot appears correctly, however, can not find way of removing coloured axis join lines (shown on graph below), make graph unsightly.
i have searched forums , not found similar question, appreciated.
thank you
code extract used plot:
code based on example given here: http://code.activestate.com/recipes/578256-script-that-compares-various-interest-rate-term-st/
from pylab import plot, title, xlabel, ylabel, show r0 = 0.5 # current uk funding rate b = 2.0 # 1 % long term interest rate = 0.1#speed of reversion beta = 0.2#sd n = 1 # number of simulation trials t = 15. # time of projection m = 15. # subintervals dt = t/m # difference in time each subinterval r = np.zeros(shape=(n, m), dtype=float) # matrix hold short rate paths #loop used simulate interest rates , plot points in np.arange(1,m): r[j,i] = r[j,i-1] + a*(b-r[j,i-1])*dt + beta*sqrt(dt)*standard_normal(); plot(np.arange(0, t, dt), r[j],linestyle='--') show()
if understand correctly, plotting lines j index.
what want r[0,:] first simulation. if so, after next j for-look, this
figure() # create new figure canvas plot(np.arange(0, t, dt), r[0,:], ,linestyle='--')
does solve problem?
(edit) then, problem need in intermediate results. took max of intermediate result , plotted thicker line.
from pylab import * r0 = 0.5 # current uk funding rate b = 2.0 # 1 % long term interest rate = 0.1#speed of reversion beta = 0.2#sd n = 1 # number of simulation trials t = 15. # time of projection m = 15. # subintervals dt = t/m # difference in time each subinterval r = np.zeros(shape=(n, m), dtype=float) # matrix hold short rate paths temp = [] # save intermediate results j = 0 clf() x = np.arange(0, t, dt) #loop used simulate interest rates , plot points in np.arange(1,m): r[j,i] = r[j,i-1] + a*(b-r[j,i-1])*dt + beta*sqrt(dt)*standard_normal() temp.append(r[j,:]) plot(x, r[j,:],linestyle='--') results = np.array(temp) plot( x, results.max(axis=0), linewidth=2 )
(edit2)
actually, final result same thing max. so
plot(x, results[-1,:])
is enough...
Comments
Post a Comment