Hi all,
The plotting module on which I have been working some time ago got
merged (thanks Chris and thanks to all the reviewers).
A number of ipython notebooks with detailed examples were merged as
well. I have converted them to PDFs so those of you that do not use
ipython-notebook can also consult them. (The formating is bad...)
Plots are implemented as `Plot` objects containing a list of
(Data)`Series` objects. The `Series` objects know what information to
provide to the plotting backend and `Plot` objects know how to operate
on them. `Plot` objects do indeed behave as a list of `Series`
objects. `plot_object[i]` returns the i-th `Series` object, for
instance. There is `Plot.extend` in order to merge two plot objects
and `Plot.append` in order to add a series object.
The attachments:
==============
plot_intro
-------------
= plot_intro describes the module. It explains setting titles,
legends, labels. More importantly it exemplifies all the different
inputs supported by the `plot` function:
=== `plot(expr1, expr2, ... range1, range2, ...)` depending on the
number of expressions, ranges and free variables will plot lines,
parametric lines, 3d parametric lines, surfaces and parametric
surfaces (eg `plot(x*y, (x,0,2), (y,0,2))` will plot a surface and
`plot(sin(u), cos(u), u, (u,0,10))` will plot a 3d parametric line).
=== removing the ranges (eg `plot(x*y, (x,), (y,))`) will use default ranges
=== removing the free variables (eg `plot(x*y, (0,2), (0,2))`) will
detect them automatically
=== removing both ranges and free variables (eg `plot(x*y)` will
detect the variables automatically and use default ranges)
=== using a list of expressions instead of a single expression (eg
`plot([x, x**2], (x, 0, 1))`) will plot them all. This also works if
you remove the range and/or free variable. This works not only for
lines but also for surfaces (eg `plot([x*y, x**2*y], (x,1,2),
(y,1,2))`)
=== `plot` can accept both `Plot` and `Series` objects as arguments
plot_discont
-----------------
= plot_discont shows how this module fails miserably on discontinuous
functions. After this gsoc it is possible that it will work a bit
better (there was already promising work on the adaptive sampling)
plot_gallery
----------------
= plot_gallery shows an amusing example. Please add more *amusing*
examples there.
plot_colors
---------------
= plot_colors explains how to use colors in your graphs. The color
maps are rather arbitrary at the moment (you supply only one scalar
for the color and the module uses its hardcoded colormap)
=== The idea behind coloring (and future aesthetics like width, alpha,
size, etc...) is that you provide a function that is used for
coloring. Depending on its arity different arguments are used. For
instance, if you have created a 3D parametric line you have the
following options:
====== `your_plot.line_color = lambda arg1: f(arg1)` will color using
the function `f` evaluated for the parameter (eg arg1 is the
parameter)
====== `your_plot.line_color = lambda arg1, arg2: f(arg1, arg2)` will
color using `f` evaluated for the x and y coordinates (eg arg1=x,
arg2=y)
====== `your_plot.line_color = lambda arg1, arg2, arg3: f(arg1, arg2,
arg3)` will color using `f` evaluated for the x, y and z coordinates
(eg arg1=x, arg2=y, arg3=z)
plot_advanced
============
Four cool examples:
=== A complicated expression that the previous module was not able to
plot: An integral where the free variable wrt which we plot is in the
limit of the integral.
=== An infinite sum Sum(x**-y, (x, 1, oo)) plot wrt y
=== A plot of a sum, here the interesting thing is that you can use
the option `only_integers=True` in order to plot a staircase.
=== Something that was very cool (poorman's implicit plot for the
magnetization in the Ising model of spins). However due to something
that changed in master it does not work anymore (this is a bug
unrelated to the plotting module that I will report soon). Anyway,
Bharath is working on a solution that is waaaaay cooler as part of
his gsoc project.
Warnings
========
The 3d stuff raises errors if you do NOT use the latest DEV version of
matplotlib (some bugs in their code related to coloring).
There are probably many bugs still present in the code. Any help will
be appreciated (including adding cool examples, feature requests,
documentation or simply testing). Also consider helping with this wiki
page:
https://github.com/sympy/sympy/wiki/Plotting-capabilities/
I will also try to make a blog post about this soon.
Thanks for all the help with reviewing this pull request.
Stefan