If you want advanced plotting things in SymPy it's often easier to plot
your function directly with matplotlib using something like

import numpy as np
import matplotlib.pyplot as plt
a = np.linspace(-10, 10, 1000) # Replace with your desired range and number
of points
f = sympy.lambdify(x, expr)
plt.plot(a, f(a))
# Modify the matplotlib plot using matplotlib functions here

This is more or less what sympy.plot does internally. The key here is that
lambdify() will convert a SymPy expression into a NumPy function which can
be applied to a numpy linspace and used directly with matplotlib's plot.

Aaron Meurer


On Thu, Jun 27, 2019 at 1:33 PM Lee Smith <leesmith...@gmail.com> wrote:

> Yep.  Well I will continue to look into this.  Of course, if I just did
> everything in matplotlib ... no problemo CODE ON !
>
> On Thu, Jun 27, 2019 at 11:59 AM Oscar Benjamin <
> oscar.j.benja...@gmail.com> wrote:
>
>> I guess it depends what environment you use (I used ipython). Looks like
>> you're using Jupyter and I'm not sure how to plotting works there.
>>
>>
>> On Thu, 27 Jun 2019 at 19:24, Lee Smith <leesmith...@gmail.com> wrote:
>>
>>> Thank you !
>>>
>>> Actually I tried this and got TWO graphs.  One just the grid then the
>>> functions!
>>> Suggestions?
>>> [image: Sympy_grid.PNG]
>>>
>>> On Wed, Jun 26, 2019 at 3:26 AM Oscar Benjamin <
>>> oscar.j.benja...@gmail.com> wrote:
>>>
>>>> Hi Lee,
>>>>
>>>> SymPy's plotting module uses matplotlib so it is reasonable to use the
>>>> matplotlib API for adding a grid.
>>>>
>>>> I just tried this and it works fine:
>>>>
>>>> In [1]: plot(x**2)
>>>> Out[1]: <sympy.plotting.plot.Plot at 0x7efd2fab3128>
>>>>
>>>> In [2]: from matplotlib.pyplot import grid
>>>>
>>>> In [3]: grid()
>>>>
>>>> Oscar
>>>>
>>>> On Wed, 26 Jun 2019 at 01:59, Lee Smith <leesmith...@gmail.com> wrote:
>>>> >
>>>> > Greetings:
>>>> >
>>>> > I want to display a grid in a sympy plot.
>>>> >
>>>> > The sympy.doc page only discusses mesh grids.
>>>> >
>>>> > On searching through Google, I found only one result that suggested
>>>> using matplotlib.pyplot in addition to the sympy.plot(...) method.
>>>> >
>>>> > This should be simple and I am surprised that it is not asked more.
>>>> >
>>>> > Thanks in advance,
>>>> > lee
>>>> >
>>>> > --
>>>> > You received this message because you are subscribed to the Google
>>>> Groups "sympy" group.
>>>> > To unsubscribe from this group and stop receiving emails from it,
>>>> send an email to sympy+unsubscr...@googlegroups.com.
>>>> > To post to this group, send email to sympy@googlegroups.com.
>>>> > Visit this group at https://groups.google.com/group/sympy.
>>>> > To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/sympy/01a492c1-f8df-4810-b413-063f65ce4fa1%40googlegroups.com
>>>> .
>>>> > For more options, visit https://groups.google.com/d/optout.
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "sympy" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to sympy+unsubscr...@googlegroups.com.
>>>> To post to this group, send email to sympy@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/sympy.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/sympy/CAHVvXxRSY%3DJ4sLs6wfePiB921ThqpYazi8MWu88mQjMtia7iJQ%40mail.gmail.com
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "sympy" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to sympy+unsubscr...@googlegroups.com.
>>> To post to this group, send email to sympy@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/sympy.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/sympy/CAJTRwDpG6dT9ELCWcUaSP6dmTOznaFHKS6LXOmXsZY%2BpM%3D9wNw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/sympy/CAJTRwDpG6dT9ELCWcUaSP6dmTOznaFHKS6LXOmXsZY%2BpM%3D9wNw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sympy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to sympy+unsubscr...@googlegroups.com.
>> To post to this group, send email to sympy@googlegroups.com.
>> Visit this group at https://groups.google.com/group/sympy.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/sympy/CAHVvXxQa5nseLq5v04U3Wz06sJnsYa9sNj_8zMPsJznSmB5mYw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/sympy/CAHVvXxQa5nseLq5v04U3Wz06sJnsYa9sNj_8zMPsJznSmB5mYw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+unsubscr...@googlegroups.com.
> To post to this group, send email to sympy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/CAJTRwDpLXZVRjds0Nj0YvSHOAC3kLRpy%3D15PQfowXiOPerc3tw%40mail.gmail.com
> <https://groups.google.com/d/msgid/sympy/CAJTRwDpLXZVRjds0Nj0YvSHOAC3kLRpy%3D15PQfowXiOPerc3tw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6Ko7PLoi%2B9a7Ur%3DVGxZMiqQgEwmgGKhqQ%3DZQG-X64_RRQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to