GSoC 2014 Application Shashank Aggarwal:Improving the plotting module

shashank-agg edited this page Mar 14, 2014 · 4 revisions
Clone this wiki locally

**Name:**Shashank Aggarwal

About me: I am a 2nd year CSE student pursuing BTech in National Institute of Technology, Karnataka.

Programming Details:

Platform and Editor: I use Ubuntu 12.04 LTS for my work machine.I have used Git, and use Sublime Text as the editor of choice.

Programming experience: I have used python for about 2 years, and C/C++ for 4 years.I have worked on the following projects:

  • A Twitter data mining program to rank countries based on average user activity. This was written in Python, and used matplotlib(mtl) for plotting the resultant graphs.

  • As a group project, designed a merge tool (similar to Meld) for a website allowing users to learn Git interactively.The website is an ongoing project, with plans to include more courses.

  • Currently working on an online architectural simulator which can be used for designing home interiors.Uses Threejs for the graphics.


  • I use python wherever possible as it provides many packages, and has a large community.In the past,I have used libraries such as Tkinter,lxml,matplotlib,selenium etc.

  • A particular feature of python I find extremely useful/interesting is the 'yield' keyword.It allows creating generators, which generate values when required.

Project details:

  • The project aims at improving the current sympy plotting module.Many of the ideas mentioned in the ideas page can be implemented to improve the usability and functionality.This would especially help first time users who can use sympy as a well-equipped plotting tool.

  • Plotting can serve as the entry point for a user into sympy,getting him acquainted with sympy terminology such as symbols,equations etc.

  • I have applied only for sympy this year as a GSoC mentoring organization since I am interested in python, and have worked in the past with with mtl. Also I look forward to contributing to sympy Live and sympy Gamma in the future.I plan to work for the required 40 hours a week.In case I am unavailable for a week or so, I will inform my mentor beforehand, and catch up before/after.

Project work:

  • 1.Manipulation of plot parameters: This can be implemented using a combination of mtl widgets (sliders,check_buttons etc.).I've already sent a PR implementing a span_selector.Some of the widgets which can be implemented are point highlighting,graph info. at particular points, adding more subplots to the same figure for easier comparision etc.There are a lot of possibilities in this regard, and a rich set of widgets could make the plot much more informative.

  • 2.Animations: The plots can be manipulated using mtl's Animation base class.This would help visualise graphs better.For example, following animations can be provided: 1.Animations showing simple graph operations such as adding/subtracting 2 plots. 2.Moving along the domain to show the entire graph etc. 3.Variation of function value,slope etc. with x.

  • 3.Sampling rate and asymptote detector: Currently 3D plots use numpy's linspace to partition the range of plotting into equal parts. However finer details on the surface, such as sharp protrusions, may be skipped, especially in cases where the number of points plotted is small or range (of x and y) is really large.Therefore, a variable sampling rate can be used, and this would be dependent on the slope of the surface, thus involving partial derivatives(using sympy's diff()).

A simple asymptote detector can be implemented by clipping the graph beyond a certain point of very high value.A line representing the asymptote could also be drawn.This would involve finding the slope of the graph at a far-away point(tending to infinity), and drawing a line with that slope close to that point.

  • 4.Domain detection : Requires searching for points of intersection in the graph (asymptotes,period,discontinuity,sharp ends(non-differentiable) etc.). I've submitted a PR for searching for periodicity and plotting based on the period calculated.

5.Additional features:

  • 5.1.Plotting objects from geometry module: According to me, this can be implemented in two ways: 1 Using mtl's patch class.This can be implemented directly by passing the geometry parameters to mtl.
    2 Using sympy's implicit_plot.For circles and polygons, implicit equations can be generated using their parameters, and these equations can be plotted.For polygons, their convex hulls can be used to obtain the line equations, and these can be plotted.

  • 5.2.Vector-fields: Implementable using mpl's streamplot() function.

  • 5.3. Include features similar to those in Mathematica. Mathematica plots provide options such as clipping,filling,plot range etc.This can be included into sympy.

6.Implement a Mayavi backend for 3D plotting: This would be a much better way of plotting 3D plots as compared to mtl.It provides a simple API, and works well with numpy. Also, provides many built-in options, including a UI.

Tentative schedule:

Week 1:

  • Learning/Using available mpl widgets.
  • Designing relevant widgets using a combination of mtl widgets.

Week 2:

  • Including the designed widgets into sympy.
  • Make sure the widgets handle various graphs.

Week 3:

  • Deciding which animations would be required/most useful.
  • Implementing the animations into sympy.
  • Send first PR for implemented functionalities.

Week 4 and 5:

  • Read about sampling of 3D surfaces, and optimal division of plotting range.
  • Implementing sampling algorithm, and checking for effectiveness.
  • Optimal cut-off for the asymptote detector.

Week 6:

  • Learning about informative domain of plotting.
  • Implementing the required/most important factors affecting the plot informativeness.

Week 7:

  • Buffer for implementing incomplete objectives.
  • Reading/understanding the sympy geometry code base for next week.

Week 8:

  • Implementing plotting of sympy geometries.
  • Testing for various geometries.
  • Send second PR with changes.

Week 9 and 10:

  • Implementing vector field plotting.
  • Checks for different vector fields.
  • Including mathematica features.

Week 11:

  • Writing the basic mayavi backend class.
  • Testing with various 3D graphs.

Week 12:

  • Developing mayavi functionality.
  • Testing with backend class,documentation for mayavi.

Week 13:

  • Completing any unfinished work.
  • Correcting bugs.
  • Final PR

Patches submitted:

  1. Included a domain-detection tool for periodic functions.

2. Included a span-selector widget for Plot class.