python - Plotting two functions simultaneously with matplotlib -
basically want graph 2 functions
g1 = x*cos(x*pi) g2 = 1 - 0.6x^2
and plot intersection, have module takes inputs close 2 lines intersections, , converges points (there's 4 of them)
but want graph these 2 functions , intersections using matplotlib have no clue how. i've graphed basic functions. appreciated
assuming can far plotting 1 function, x , g1 numpy arrays,
pylab.plot(x,g1)
just call plot again (and again) draw number of separate curves:
pylab.plot(x,g2)
finally display or save file:
pylab.show()
to indicate special point such intersection, pass in scalars x, y , ask marker such 'x' or 'o' or whatever else like.
pylab.plot(x_intersect, y_intersect, 'x', color="#80c0ff")
alternatively, mark special place along x vertical segment plotting quick little two-point data set:
pylab.plot( [x_special, x_special], [0.5, 1.9], '-b' )
i may hardcode y values on plot current project, not reusable other projects. note plot() can take ordinary python lists; no need convert numpy arrays.
if can't far plotting 1 function (just g1) need basic tutorial in matplot lib, wouldn't make answer here please go visit http://matplotlib.org/ , google "matplotlib tutorial" or "matplotlib introduction".
Comments
Post a Comment