question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

figure in matplotlib doesn't show plots created in axes

See original GitHub issue

Environment data

  • VS Code version: 1.32.3
  • Extension version (available under the Extensions sidebar): Python 2019.3.6558
  • OS and version: Windows 1709
  • Python version (& distribution if applicable, e.g. Anaconda): Ptyhon 3.7.3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): virtualenv
  • Relevant/affected Python packages and their versions: matplotlib

Expected behaviour

I am trying to practice using matplotlib in VSCode. In Jupyter, I can do the following. Basically, after I created figure & axes, if I created any plots in axes, figure will show the plot.

image

Actual behaviour

However, if I do exactly the same in VSCode, figure will return nothing. ax1’s plot cannot be shown in the figure.

image

Steps to reproduce:

import numpy as np
import pandas as pd
from fastai.imports import *

import pyodbc
import matplotlib.pyplot as plt
import seaborn as sns

from IPython.display import display

fig = plt.figure()

ax1 = fig.add_subplot(2, 2, 1)
ax2 = fig.add_subplot(2, 2, 2)
ax3 = fig.add_subplot(2, 2, 3)

ax1.hist(np.random.randn(100), bins=20, color='k', alpha=0.3)

fig

It will have different results between Jupyter and VSCode. Figure should be able to show what has been plotted in axes.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mukerongcommented, Sep 10, 2019

@ronglums sorry for the late reply. Looks like it works with the light theme! Is it possible to make matplotlib supports the dark theme? I really like the dark theme and don’t want to change to light because of matplotlib.

image

0reactions
greazercommented, Oct 18, 2019

dupe of microsoft/vscode-jupyter#2904

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why are my plots in matplotlib not showing the axes
I think the line ax = fig.add_axes([0,0,1,1]) is the problem -- it uses all figure space for the plot and leaves none for...
Read more >
figure in matplotlib doesn't show plots created in axes #3148
I am trying to practice using matplotlib in VSCode. In Jupyter, I can do the following. Basically, after I created figure & axes,...
Read more >
Resolved: Matplotlib figures not showing up or displaying
Ever try to plot a matplotlib figure and not have it display to your screen? I'll show you how to fix when matplotlib...
Read more >
How To Display A Plot In Python using Matplotlib - ActiveState
Click to display a Plot in Python using Matplotlib's two APIs. Create simple, scatter, histogram, spectrum and 3D plots.
Read more >
matplotlib.pyplot.show — Matplotlib 3.6.2 documentation
Enable interactive mode, which shows / updates the figure after every plotting command, so that calling show() is not necessary.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found