Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ENH]: callable arguments to the high level plot functions #20926

Closed
@akhmerov

Description

@akhmerov

Problem

I often find myself using an equivalent of this code:

x = np.linspace(x_min, x_max)
pyplot.plot(x, f(x))

This is unnecessarily verbose, and if written in one line has redundancy:

pyplot.plot(np.linspace(x_min, x_max), f(np.linspace(x_min, x_max)))

Proposed solution

It would be convenient if .plot and similar high level plotting routines identified callable arguments and if possible evaluated those with array arguments. I imagine the amount of meaningful combinations would be limited.

Additional context and prior art

Providing functions as input to plotting routines and letting those take care of the evaluation is a common pattern.

  • Julia has such interface
  • Mathematica goes a step further and determines how to sample the function. This is out of scope for matplotlib.
  • Similarly matlab has fplot

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions