2

I am running Python, and I am creating a series of histograms in a for-loop like this:

hist_dict = {}

for data, name in zip([mon, tue, wed, thu, fri], 
['Monday','Tuesday','Wednesday','Thursday','Friday']):
    plt.figure()
    plt.title("Call Distribution for " + name)
    plt.xlabel("Number of Daily Calls")
    plt.ylabel("Number of Days")
    plt.xlim(0, 1200)
    hist_dict[name] = plt.hist(data, bins=24)

Once the images are saved to my dictionary (or a list, I don't know if it matters), can I call them and show them? I have tried

hist_dict["Monday"].show()
plt.show(hist_dict["Monday"])
hist_dict["Monday"]

and nothing seems to work. If this doesn't work, what is the best way to save plots locally (not as a png file) so that I can arrange into a subplot setup?

jdbul33
  • 165
  • 1
  • 8
  • 1
    Try following the solution given [here](https://stackoverflow.com/questions/3783217/get-the-list-of-figures-in-matplotlib). Plot everything without showing and then iterate using `plt.get_fignums():` and show/save them – Sheldore Sep 20 '18 at 14:51
  • If this question is being asked with the premise to use its answer for creating subplots, that's not going to work. Subplots are always part of a figure and shouldn't be moved around. You would hence rather create the plot you want plotting to an axes (a subplot) when necessary. – ImportanceOfBeingErnest Sep 21 '18 at 00:26

0 Answers0