Home > Blockchain >  Matplotlib background matches vscode theme on dark mode and can't see axis
Matplotlib background matches vscode theme on dark mode and can't see axis

Time:12-18

I just got a new PC and downloaded visual studio code. I'm trying to run the exact same plots as the code I had on my other PC (just plt.plot(losses)) but now matplotlib seems to have a dark background instead of white:

enter image description here

I found this and this that had opposite problems. To clarify, I'm asking how to change the matplotlib background plots to white (note that in my other machine I didn't have to hard code any matplotlib background information so I think it's a visual studio problem, but couldn't figure it out)

CodePudding user response:

Difficult to be sure since I cannot reproduce your problem.

Two things to try (both presume that you import matplotlib using import matplotlib.pyplot as plt):

  1. if you use plt.figure, add facecolor='white' parameter. Or try to run fig.set_facecolor('white') (fig here is the variable that stored the figure which facecolor you are changing. If you don't have any, use plt.gcf().set_facecolor('white') once the figure is created; gcf() returns current figure, see this doc).
  2. Try to change plt.style.context as in this matplotlib example.
  • Related