> From: Jerzy Karczmarczuk [mailto:jerzy.karczmarc...@unicaen.fr] 
> Sent: Sunday, May 27, 2012 12:56
> 
> Gordon Hardmant :
> > I ...cannot find a simple way to stop a curve being drawn once it crosses
> > another curve. In the attached example, I am trying to draw the solid
> > curve only until it intersects the dashed one. I have tried using the
> > numpy.where() method, but it does not seem to be the right way to go
> > about it- I end up having to write FOR loops and so on, and that does
> > not make use of the vectorization advantages of numpy.
> Try to insert just before plot(...) the following two lines:
> 
> igc=np.sign(ig_bdry-ig_d2)
> ig_d2[igc!=igc[1] ]=np.nan

Or, if you want to preserve the original data, index it with a boolean array:

    under = (ig_d2 <= ig_bdry)
    plt.plot(vg[under], ig_d2[under])

If you need to determine the intersection more precisely, you could define a
function of vg, V, L, Ts, and d that returns the difference between ig_CRM and
ig_CCM for those parameters, then use a root-finding routine [1] to
numerically find the vg for which that function returns essentially zero.

[1] http://docs.scipy.org/doc/scipy/reference/optimize.html#root-finding


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to