Skip to content

Same environment but different results with saving/loading a pickled figure #13586

Closed
@Eriz11

Description

@Eriz11

I faced an issue regarding how to load a figure after pickling it. I don't know if this might be a bug (in VSCode), the very nature of the package or other things.

The saving process of the figure goes smoothly. Code for reference:

with open('cdImg.pickle', 'wb') as f:
                pickle.dump(f1, f)

However, when I load the figure in Ipython with the following code:

In [1]: import pickle

In [2]: import matplotlib.pyplot as plt

In [3]: candleFig = pickle.load(open('cdImg.pickle', 'rb'))

In [4]: candleFig.show() ### Here plt.show() also works. 

The image shows perfectly. Using that same code in VSCode (within the same env; hence, same python and package versions) I don't get the figure, but the program executes perfectly and without any error.

In contrast, if I execute the following in VSCode:

import pickle
import matplotlib.pyplot as plt

def loadImage():
   
   candleFig = pickle.load(open('cdImg.pickle', 'rb'))
       
   plt.show() ### In the IPython example it was: candleFig.show()
   
if __name__ == '__main__':
   
   loadImage()

It loads the image perfectly. Notice the change from candleFig in ipython to plt.show() in VSCode.

¿Is there anything I'm missing about the candleFig.show() not working in VSCode?

Matplotlib version: 3.0.2
Python version: 3.6.8
Ipython: 6.4.0
Pickle version: 4.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions