2

I am trying to create a box plot from a data set and then change background color for each of the subplots:

url = "https://raw.githubusercontent.com/jbrownlee/Datasets/master/iris.csv"
column_names = ['sepal-length', 'sepal-width', 'petal-length', 'petal-width', 'class']
data_set = read_csv(url, names=column_names)


data_set.plot(kind="box", subplots=True, color="yellow", layout=(2, 2), sharex=False, sharey=False)

pyplot.subplot(221).set_facecolor("red")
pyplot.subplot(222).set_facecolor("purple")
pyplot.subplot(223).set_facecolor("green")
pyplot.subplot(224).set_facecolor("blue")

pyplot.show()

I do get the colored subplots, however, I keep getting the warning message:

MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.  In a future version, a new instance will always be created and returned.  Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.

Does anyone know how to fix this issue?

Kris
  • 562
  • 5
  • 17

1 Answers1

2

This seems to be an ongoing issue in Matplotlib which hasn't been resolved as of today. From reading the thread here here, there doesn't seem to be an imminent risk of Deprecation.

However, if you want this message to go away, you can try what this user tried here.. The user here replaced fig.subplot() with fig.add_subplot()