# Plotting of arbitrary functions

**URL:** <https://brian.discourse.group/t/plotting-of-arbitrary-functions/399>\
**Category:** Support\
**Created:** [4 June 2021 12:49 UTC](https://brian.discourse.group/t/plotting-of-arbitrary-functions/399 "2021-06-04T12:49:11Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mstimberg](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/mstimberg/32/11_2.png) [@mstimberg](https://brian.discourse.group/u/mstimberg)\
**Post date:** [4 June 2021 14:46 UTC](https://brian.discourse.group/t/plotting-of-arbitrary-functions/399/2 "2021-06-04T14:46:17Z")

</div>

Hi. I agree that this is something that we should support in a more convenient way… Here’s what I usually do: I set the function argument (often the membrane potential `v`) to the full range of values in a `NeuronGroup`, and then directly plot the variable that is described by an equation. This has the advantage of not having to change the equations and is also not actually running a simulation (the expression gets directly evaluated by numpy). It is still not a perfect solution, since you usually have to create a `NeuronGroup` just for this purpose (if the existing `NeuronGroup` does not happen to have exactly the size you want for the resolution). In your example, `x` would probably be a differential equation, so it would look something like this:

```auto
import matplotlib.pyplot as plt
import numpy as np
from brian2 import NeuronGroup

group = NeuronGroup(100, # the resolution I want
                    """dx/dt = -x / (10*ms) : 1 # this would be v typically
                       y = x**2 : 1 # the function I'm interested in""",
                    method='euler')
group.x = np.linspace(-100, 100, len(group))

plt.plot(group.x, group.y)
plt.xlabel('x')
plt.ylabel('x*x')
plt.savefig("brian_plotting.png")

```

This will give you the same plot.

---

_[View the full topic](https://brian.discourse.group/t/plotting-of-arbitrary-functions/399)._
