ok, I know how to use init_printing to get sympy to automatically render IPython output using MathJax.
from sympy import init_printing
init_printing()
How do I get it to stop? (Yeah, I could reset my notebook but I'd like to turn it on just for a few cells and turn it off again.)
found it (had to UTSL):
sympy.init_printing(pretty_print=False)
Related
I am using the following code and python stops responding after executing plt.show(). I noticed removing the next input command removes the error, however, I need to retain both commands.
Next, I tried to sandwich plt.pause(2) between the two commands but here, python stops after I press any key once plot is displayed. Please help:
PS: I am using Atom editor with python 3.7.4
import matplotlib.pyplot as plt
import numpy as np
from scipy.optimize import fsolve
def f(x):
y=2.0*np.sin(x**2)+3.0*x-10.0
return y
x=np.linspace(-5,3,100000)
plt.ion()
plt.plot(x,f(x))
plt.show()
plt.pause(2)
yy=input("pppp")
print(fsolve(f,2))
You have the following line in your code plt.ion(). If I remove the parentheses from the end of the line the program seems to work fine in Atom.
this command output latex in online Env
solve(x**2 - 33*x + 20*13-14**2, x)
same command outputs a plaintext on my local Env.
a simpler one could be rendered successfully.
did I missing something?
You need to initiate session first by calling init_session()
If you plan to work in an interactive calculator-type session, the init_session() function will automatically import everything in SymPy, create some common Symbols, setup plotting, and run init_printing()
from sympy import init_session
init_session()
x = 5
solve(x**2 - 33*x + 20*13 - 14**2, x)
In Spyder 2 (Anaconda distribution) and in the IPython QT Console I'm able to print results of symbolic calculations (from an answer I got for a previous post) but I can't get equations in strings to print with the a IPython's Rich Display System:
from sympy import *
from IPython.display import display, Math
init_printing(use_unicode=False, wrap_line=False, no_global=True)
x, y, z = symbols('x y z')
#----- prints correctly
ii = integrate(x**2 + x + 1, x)
display(ii)
#----- does not print
Math(r'F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx')
The above prints the results of the integrate correctly but the Math() does not print (no error -- just skips it). Note it all works in SciPy web notebook.
Thank you!
The Math class doesn't generate the rendered image from your Latex, that's why it doesn't work directly.
To get what you want you need to use this code
from IPython.display import Image, display
from IPython.lib.latextools import latex_to_png
eq = r'F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx'
data = latex_to_png(eq, wrap=True)
display(Image(data=data))
Then you will see the right image
Hello guys im still having the problem, whe i use
from IPython.display import display, Math, Latex
display((Math(r'P(Purchase|Male)= \frac{Numero\ total\ de\ compras\ hechas\ por\ hombres\}{Total\ de\ hombres\ en\ el\ grupo\} = \frac{Purchase\cap Male}{Male}')))
on jupyter it works fine, but when i do the exact same code on spyder it doesnt work
im using python 3.6 , spyder 3.3.3
also i tried the marked asnwer but latex_to_png makes a NoneType Object on spyder
I'm working to migrate from MatLab to python in Sage.
So I use these commands and I faced this error in Sage:
from scipy import misc
l = misc.lena();
import pylab as pl
pl.imshow(l)
The Error or message (i don't know) is:
matplotlib.image.AxesImage object at 0xb80198c
And it doesn't show any image
It's not an error, just print the object that method returned.
There are two ways to show the figure:
Add pl.show() after calling pl.imshow(l)
Use ipython --pylab to open your python shell,
That is an object being returned from pylab after using the "imshow" command. That is the location of the Axes image object.
documentation:
http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.imshow
Looks like it says it displays the object to the current axes. If you havent already created a plot I imagine you wont see anything
Simple google search suggests this might be what you are looking for
http://docs.scipy.org/doc/scipy/reference/generated/scipy.misc.lena.html
from scipy import misc
l = misc.lena();
import pylab as pl
pl.imshow(l)
####use this
pl.show()
When I run this simple code:
from pylab import *
import numpy as np
X = [];
Y = [];
for i in range (0,10):
X.append(i)
Y.append(i)
plot(X,Y)
show()
I don't get any window. I tried to replace show with draw with the same result.
I'm using python version 3.2.2
How can I show the window/plot than (apart from printing it to file and open the file).
Note, I'm using this example:
http://matplotlib.sourceforge.net/examples/api/custom_scale_example.html
I don't think numpy or scipy have a stable release for 3.2 yet.
Unless it's important to you that you use python 3.2, try to install python 2.7 instead. Everything should work fine there.