Search code examples
pythonmatplotlibhistogramfigure

Plot border color change


How can I change border color from dark gray to white? I have tried a few things but not success.

here is code and figure.

Image is here

import numpy as np
import matplotlib.pyplot as plt
plt.style.use('classic')
from mpl_toolkits.axes_grid1 import make_axes_locatable
import pylab as plt2

def plot_hist(*argv, titles):
  """
  plots the historgram of the input phase maps
  """
  for i in range(len(argv)):
      hist = np.histogram(argv[i].ravel(), bins=100)
      plt.plot(hist[1][1:], hist[0])
  plt.xlabel("phase values")
  plt.ylabel("frequency")
  plt.title("Histogram Analysis")
  plt.grid()
  if titles is not None:
    plt.legend(titles) 
  fig=plt.figure(facecolor='white') 
  plt.show()

I tried to change facecolor to white but it did not work.


Solution

  • You are actively setting the style to classic, which sets figure.facecolor to grey (see the style parameters on github). Is this on purpose?

    You can either remove plt.style.use('classic') to use the default style or set figure.facecolor to white with the following:

    plt.rcParams['figure.facecolor']='white'