To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAHVvXxRnbKS%3DNpwmKA7JRtDO%3Du7d-kV50pzU5VXH34roA8m7Ww%40mail.gmail.com.
--
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CALkUZDmkP7uzNRTn%3DLDw3BB8fNTKPN8u_ydG7xexwNbJ-wavFw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAP7f1AgBoO2w4Bn%2BB2nreoOewD53Eu%2B%2BhVH2XVum1Ea9ovAG%2Bw%40mail.gmail.com.
Hi everyone,
The plotting.plot and plotting.plot3d functions are very nice, and produce good looking output, but I can't see any way to create arbitrary plots that would not have axes, but would be composed of lines, points, filled regions, and text positioned as desired, for example:
A circuit diagram
Other engineering diagrams
Fractals
Organic chemical structures
I am sure there are packages out there to do any one of those tasks, but what do those packages use to generate their plotting output?
Since plot() returns a plot object that can be subsequently rendered, I have wondered if the answer is to actually construct a plot object 'by hand'.
Any hints would be welcome,
David
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAHVvXxT_8H-0yESmso8eZ%2BOqtQBHOG-_Q6DK4fUrDirre6pS1g%40mail.gmail.com.
IMO, Oscar is suggesting a nice idea. Using wrappers for the APIs already existing for plotting just slows down the computation of overall results. If the SymPy wrappers for plotting module aren't making any difference in the algorithms for plotting then may be we can remove them though it would be a drastic change. Other approach can be to stop extending it further and just focussing on fixing the current bugs.My views are based on a high level idea of plotting module, someone with more experience should take the decision regarding this.
Looking at the MatplotLib site, I see most of the examples have axes, but gratifyingly there are a few that don't. There is even a Mandelbrot example (without axes) so if you can plot that, I imagine you can do just about anything!
I don't think it would be a good idea to make drastic changes to SymPy - because that just creates confusion, and stability counts for a lot - but it might be nice to change the documentation to point directly at Matplotlib, because otherwise users get the impression that the plotting features in SymPy are much less complete than they really are.
David
The sympy plotting module is mostly a wrapper around matplotlib. You can use matplotlib directly for a lot of the things you suggest. I think it would be better if sympy's plotting module didn't try to wrap up other libraries as "backends" but instead focussed on documenting how it should be used in combination with the underlying plotting libraries.
Hi everyone,
I have followed the advice to use matplotlib from several members
of the group. It certainly looks like the right way to proceed,
but I can't get even the simplest Matplotlib program to actually
produce a plot.
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
fig, ax = plt.subplots()
ax.plot(t, s)
ax.set(xlabel='time (s)', ylabel='voltage (mV)',
title='About as simple as it gets, folks')
ax.grid()
fig.savefig("test.png")
plt.show()
It reports: ModuleNotFoundError: No module named 'tkinter'
However when I try to install that module, I get:
ERROR: Could not find a version that satisfies the requirement
tkinter (from versions: none)
ERROR: No matching distribution found for tkinter
This is the same python instalation that is running Sympy plots successfully, though only after I followed the advice of someone here to use
matplotlib.use("Qt5Agg")
I am running SymPy 1.5 and Python 3.7 under 64-bit Windows 10.
Thanks,
David
Matplotlib has several backends, some of which work better than others. The use() function changes the backend. I would also recommend installing matplotlib via Anaconda. That will come with all the things you need to show plots.
Thanks Aaron, but since Matplotlib is presumably operating correctly with SymPy, I am concerned that if re-installing it changes something, it won't then work with SymPy!
Incidentally, I think the pitfalls in actually getting plotting running under Windows, would make an excellent subject for the new documentation you are planning.
David
Thanks Aaron, but I took a look at Anaconda, hoping that it was a better version of pip, but it is a huge sprawling package weighing in at almost 1 Gigabyte of storage - even in its compressed form. It seems to want to take over my entire python experience. I'd really like to know how SymPy manages to use Matplotlib to create plots, which it does correctly using my current python setup, and which would presumably solve the problem.
I have already tried executing matplotlib.use("Qt5Agg"), which Oscar recommended some time back and which got SymPy plots working nicely under 64-bit Windows 10.
I chose to test a very simple test program from the Matplotlib examples:
import matplotlib import matplotlib.pyplot as plt import numpy as np # Data for plotting t = np.arange(0.0, 2.0, 0.01) s = 1 + np.sin(2 * np.pi * t) fig, ax = plt.subplots() ax.plot(t, s) ax.set(xlabel='time (s)', ylabel='voltage (mV)', title='About as simple as it gets, folks') ax.grid() fig.savefig("test.png") plt.show()
Best wishes,
David
I resolved this problem, and I think it might be of some
interest.
Some time ago, Oscar recommended that I use
"matplotlib.use("Qt5Agg") in order to make SymPy plots work -
which they now do. However, this trick still did not permit a
Matplotlib program to execute. However, it turns out that if I do
any plot using SymPy, e.g. sympy.plot(x**2,show=False)
it connects something that then lets matplotlib execute matplotlib code.
David
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAP7f1AgBoO2w4Bn%2BB2nreoOewD53Eu%2B%2BhVH2XVum1Ea9ovAG%2Bw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAP7f1AgBoO2w4Bn%2BB2nreoOewD53Eu%2B%2BhVH2XVum1Ea9ovAG%2Bw%40mail.gmail.com.