Skip to content

"%matplotlib notebook" not working in jupyter notebook #4056

@Bipul-Harsh

Description

@Bipul-Harsh

Environment data

  • VS Code version: 1.51.1
  • Jupyter Extension version (available under the Extensions sidebar): v2020.11.392013122
  • Python Extension version (available under the Extensions sidebar): 3.8.6
  • OS (Windows | Mac | Linux distro) and version: Windows 10 20H2
  • Python and/or Anaconda version: 3.8.6
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): XXX
  • Jupyter server running: Local | Remote | N/A

Expected behaviour

Should show interactive window

Actual behaviour

Error Reporting:
ReferenceError: IPython is not defined

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Install Python extension by Microsoft
  2. Open Jupyter notebook (Inside vscode with help of extension)
  3. Type "%matplotlib notebook"
  4. Enter code:
    ##Start
    import numpy as np
    import matplitlib.pyplot as plt
    import matplotlib.animation as animation
    n = 100
    x = np.random.randn(n)

def update(curr):
#check if animation is at the last frame, and if so, stop the animation a
if curr == n:
a.event_source.stop()
plt.cla()
bins = np.arange(-4, 4, 0.5)
plt.hist(x[:curr], bins=bins)
plt.axis([-4,4,0,30])
plt.gca().set_title('Sampling the Normal Distribution')
plt.gca().set_ylabel('Frequency')
plt.gca().set_xlabel('Value')
plt.annotate('n = {}'.format(curr), [3,27])

fig = plt.figure()
a = animation.FuncAnimation(fig, update, interval=100)
##END

Logs

Output for Jupyter in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Jupyter)

XXX

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from poster

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions