Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
P pyOPALTools
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 8
    • Issues 8
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 1
    • Merge requests 1
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Code Review
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • OPAL
  • pyOPALTools
  • Issues
  • #15

Closed
Open
Created May 30, 2018 by ext-roussel_r@ext-roussel_rDeveloper

Plotting Recommendation

The plotting modules could be improved by using the object oriented approach to the matplotlib API. Functions returning matplotlib.pyplot.Figure or matplotlib.pyplot.Axes objects are far easier to work with when customizing plots. See from https://matplotlib.org/api/pyplot_summary.html

Most of these functions also exist as methods in the matplotlib.axes.Axes class. You can use them with the “Object Oriented” approach to Matplotlib. While it is easy to quickly generate plots with the matplotlib.pyplot module, we recommend using the object-oriented approach for more control and customization of your plots. See the methods in the matplotlib.axes.Axes() class for many of the same plotting functions. For examples of the OO approach to Matplotlib, see the API Examples.

I suggest having a kwargs argument that takes an matplotlib.pyplot.Axes object that determines if the function creates a new figure or not, ie.

def plot(x,y,ax=''):
    if not ax:
        fig,ax = plt.subplots()
    ax.plot(x,y)
    return ax

This works well for a user who creates an array of plots and wants to fill each axis with a particular plot.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking