[Numpy-discussion] Unpleasant behavior with poly1d and numpy scalar multiplication

Dave Hirschfeld dave.hirschfeld at gmail.com
Mon Feb 15 08:35:11 EST 2010


Charles R Harris <charlesr.harris <at> gmail.com> writes:

> I was also thinking that someone might want to provide a better display at
> some point, drawing on a canvas, for instance. And what happens when the
> degree gets up over 100, which is quite reasonable with the Cheybshev 
> polynomials?

There may well be better ways to do it but I've found the following function to
be quite handy for visualising latex equations:

def eqview(expr,fontsize=28,dpi=80):
    IS_INTERACTIVE = is_interactive()
    try:
        interactive(False)
        fig = figure(dpi=dpi, facecolor='w')
        h = figtext(0.5, 0.5, latex,
                    fontsize = fontsize,
                    horizontalalignment = 'center',
                    verticalalignment = 'center')
        bbox = h.get_window_extent(RendererAgg(15,15,dpi))
        fig.set_size_inches(1.1*bbox.width/dpi, 1.25*bbox.height/dpi)
        show()
    finally:
        interactive(IS_INTERACTIVE)

NB: Sympy provides the latex function to convert the equation objects into 
latex as well as other ways to display the objects in the sympy.printing 
module. It shouldn't be too hard to do something similar if someone was so 
inclined!

HTH,
Dave




More information about the NumPy-Discussion mailing list