GSOC 2018 Application Subhash Saurabh: Improving the Plotting Module - Subhash-Saurabh/sympy GitHub Wiki
Improving the Plotting module
About Me
Basic Information
Name : Subhash Saurabh
University : Indian Institute of Technology, Guwahati
Major: Civil Engineering
Email: [email protected]
Github: Subhash-Saurabh
Timezone: IST (UTC +5:30)
Personal Background
My name is Subhash Saurabh a third year undergraduate at IIT Guwahati,India. I was very much interested in learning Mathematics since my high schools. After joining the university, I got exposed towards the field of Computer Science and I was very much interested in it. Even though my major is in Civil Engineering I have therefore taken many courses related to Computer Science and Mathematics such as Probability and Statistics , Real and Complex Analysis, Data Structures and Algorithms and Machine Learning.
Programming Details
Platform
I am currently using Ubuntu 14.04 LTS and Atom as my primary text editor as it is open source, there are many plugins available and most important it has autocomplete feature which helps to write code faster.
Experience
I have 2+ year of experience with python and I have used it for Data Science(pandas, numpy, sklearn) , web scrapping (BeautifulSoup), and for many other programming related work. One of the projects that I did related to programming is Genome Assembling (designing an algorithm to find the genome from its read). I have a good level of understanding of git and I think it will be sufficient to complete this project.
One of the most interesting feature of sympy is it's ability to solve indefinite integrals. For example
>>> Integral(x**4*sin(3*x),x).doit()
-x**4*cos(3*x)/3 + 4*x**3*sin(3*x)/9 + 4*x**2*cos(3*x)/9 - 8*x*sin(3*x)/27 - 8*cos(3*x)/81
Contributions
I got introduced to sympy in Nov 2017. Since then I have made several pull request to the sympy repository. Here is the list of my pull request.
Merged
- Added simplification of mul having args as units, prefixes and other arguments
- Corrected latex printing of units containing underscores
- Faster implementation of sample function in drv_types
- Made changes to resolve errors with mul and div in prefixes
- Fixed issue of wrong prefixes under multiplication
- Made changes to ensure no precision loss of Float on computing Jordan_form
- Removed backslash-escaping of square brackets
- Added abbreviated printing for units
- Resolved error during substitution of Quantities
- Fixed a typo in mechanics documentation
- Added angular quantities printing in latex and pretty
- User defined values in mul_symbol in latex
- Implemented presentation mathML printer
- Fixed issue of simplify error in sinc
- Fixed Documentation of gamma function
- Fix missing parentheses in LaTex and pprint output
Unmerged
- Added support of continuum_mechanics with units
- Added ascii printing for symbols
- Fix Problem with substitution and paranthesis handling (Sympy's Turn)
Project
Adding Backends
1. Adding Mayavi as Backend for 3D Plotting.
Mayavi is a tool for easy and interactive visualization of data, with seamless integration with Python scientific libraries. Matplotlib
does not work well with volumes (as opposed to surfaces) therefore it is important to add Mayavi
as a backend. The idea to add mayavi was also proposed in issue#6567.
Therefore class MayaviBackend
will be implemented in plotting/plot.py. Addition of this backend will enable better plotting of 3DContourPlot
.
2. Adding Bokeh as Backend for 2D Plotting.
Bokeh is a Python interactive visualization library that targets modern web browsers for presentation. Bokeh can help anyone who would like to quickly and easily create interactive plots, dashboards, and data applications.
The idea to add bokeh was also mentioned in issue #11469.
3. Adding D3.js Backend
D3.js is a JavaScript library for producing dynamic, interactive data visualizations in web browsers. It makes use of the widely implemented SVG, HTML5, and CSS standards. In contrast to many other libraries, D3.js allows great control over the final visual result.
Initial work was done in PR #2120, so required addition/changes will be made in that.
Adding various plots
1. 2D and 3D Density Plots.
A Density Plot visualizes the distribution of data over a continuous interval or time period. It is a variation of a Histogram that uses kernel smoothing to plot values, allowing for smoother distributions by smoothing out the noise.
Bokeh and Matplotlib backend can be used for 2D density plots while 3D density plots can be plotted using Mayavi.
Methods plot_density
and plot3d_density
and other required classes (2DDensityPlot ,3DDensityPlot etc) will be implemented.
2. 2D and 3D Vector Field Plots and Streamlines.
A vector field in the plane (for instance), can be visualised as a collection of arrows with a given magnitude and direction, each attached to a point in the plane
2D Vector Field can be plotted using Matplotlib
or Bokeh
as backend. For 3D we will use mayavi.
Methods plot_vector_field
and plot3d_vector_field
will bw implemented that will plot the vector field.
3. 3D Points
Request for adding this feature was made in issue #8855. Mayavi backend can be used for plotting points in 3D.
A method plot3d_points
will be implemented that will plot the points in 3D.
4. Plotting shapes from geometry class
Currently ellipse and parabola can be plotted using the plotting module. In this project I plan to implement plotting for polygons (currently a hack is used) and other remaining shapes.
Animations
The plots can be manipulated using matplotlib or mayavi Animation (mayavi is much better).This would help visualise graphs better.Following animations can be provided
-
Animations showing simple graph operations such as adding/subtracting two plots.
-
Moving along the domain to show the entire graph etc.
-
Variation of function value,slope etc. with x.
Timeline
My end-sem exams will get over on 5th May and my college will reopen on 24 July.Therefore I will be able to contribute 40-45 hours weekly to my project. Even after my college opens work load will be fairly less for initial weeks and therefore I will be able to complete my project.
Community Bonding Period (23 April - 13 May)
- During this period I will get myself more familiar with the codebase of plotting module. I will make sure that all unmerged PR relating to my project gets merged with addition/changes if required. During this period I will also discuss the project with the mentors.
Week 1 & 2 (14 May - 27 May)
- In these first two week I will add mayavi as a backend for plotting module.
- All the existing 3dplots will be plotted by mayavi.
Week 3 & 4 (21 May - 10 June)
- In these two week I will add bokeh as a backend for plotting module.
- All the existing 2dplots will be plotted by bokeh.
Week 5 (11 June - 17 June)
- In this week d3.js will be added as a backend by making necessary changes in the PR #2120.
Week 6 & 7 (18 June - 1 July)
- In these two weeks 2D and 3D density plots and vector plots will be added.
Week 8 (2 June - 8 July)
- In this week 3D contour plots and shapes from geometry class will be added .
Week 9 & 10 (9 July - 22 July)
- In these two weeks animations will be added using mayavi and matplotlib.
Week 11 (23 July - 29 July)
- In this week all documentation will be added.
- Various examples related to new plotting features will also be added.
Week 12 (30 July - 5 August)
- Any remaining work will be completed.
Week 13 (6 August - 14 August)
Final Submission
Post Gsoc
Plotting module currently needs many improvements and additions as mentioned here. After Gsoc I plan to implement those features one by one and make other necessary improvements in the plotting module.
References
- http://code.enthought.com/pages/mayavi-project.html -- Mayavi
- https://bokeh.pydata.org/en/latest/docs/user_guide/quickstart.html#userguide-quickstart -- Bokeh
- https://datavizcatalogue.com/methods/density_plot.html -- Density Plot
- https://matplotlib.org/gallery/images_contours_and_fields/plot_streamplot.html -- Vector Plot
- https://blog.krastanov.org/2013/05/14/sympy-plots-with-d3-in-ipyhton/ -- D3.js
- https://en.wikipedia.org/wiki/D3.js -- D3.js
- https://matplotlib.org/api/animation_api.html -- Matplotlib Animations
- http://docs.enthought.com/mayavi/mayavi/mlab_animating.html -- Animations mayavi