Question: I'm basically trying to write a json\_encode filter, by which I'm hoping to get a raw json object, but what I'm getting instead, is an escaped string of the json object.

Expected result:

```
{"foo":"bar"}

```

Actual result:

```
"{\"foo\":\"bar\"}"

```

Right now the only way I can get it the way I want, is by using the noescape filter, but this makes it unnecessarily more ugly

```
{$object|json_encode|noescape}

```

My json\_encode filter

```
public static function json_encode(FilterInfo $info, mixed $value): string {
    $info->contentType = ContentType::JavaScript;
    return json_encode($value);
}

```

Answer: 
It turns out I had to install ffmpeg for windows:

<https://www.wikihow.com/Install-FFmpeg-on-Windows>

Now the graph shows up but I can't see it animating. Oh well. That is an entirely different question.

[here is the end graph I made (with a couple of extra details)](https://i.stack.imgur.com/QT2r0.png)
Add this line to the beginning of your code in order to see the animation work:

```
%matplotlib notebook

```

In Jupyter Notebook (at least on Windows) specifying the GUI toolkit will allow you to see the animation updating, not just a static graph. You can read more about toolkits and user interfaces [here](https://docs.jupyter.org/en/latest/projects/user-interfaces.html).

If there is a message that says:

```
Warning: Cannot change to a different GUI toolkit: ...

```

then restart the Jupyter kernel and run the cell again to update the GUI. For troubleshooting the GUI, see [this answer](https://stackoverflow.com/questions/52703190/cannot-change-to-a-different-gui-toolkit-notebook-warning-in-jupyter).

In regards to the original question, if you set `blit = False` in `FuncAnimation` then the animation should display. Otherwise, you can add a `return blue,` statement to the `animate` function. See my code below and feel free to ask questions!

Complete Code
-------------

```
%matplotlib notebook

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.animation import FuncAnimation

def move_line(num_frames):
    x_vals = [-1.25,.75]
    y_left_array = np.linspace(9.1, 9.7, num=num_frames, endpoint=True)
    y_right_array = np.linspace(8.0, 7.5, num=num_frames, endpoint=True)

    fig = plt.figure()
    red = plt.plot(x_vals, [9.7,7.5], color = 'r', label = 'right')
    blue, = plt.plot([], [], color = 'b', label = 'wrong')

    def animate(I):
        y_vals = [y_left_array[i],y_right_array[I]]
        blue.set_data(x_vals,y_vals)
        return blue,

    anim = FuncAnimation(
        fig,
        animate,
        frames = num_frames,
        interval = 1000/30,
        repeat = False,
        blit = True
    )

    plt.show()

    return anim

animate_lines = move_line(100)

```