Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cool project, however, some suggestions for improvements #80

Open
anaderi opened this issue Jan 11, 2021 · 2 comments
Open

Cool project, however, some suggestions for improvements #80

anaderi opened this issue Jan 11, 2021 · 2 comments
Labels
bug Something isn't working docs Documentation

Comments

@anaderi
Copy link

anaderi commented Jan 11, 2021

  1. it is not obvious how to display a saved display (image)...
  2. There is a an unnecessary ambiguity for the word 'display' here. it denotes type of scrap as well as scrap output flag upon saving
  3. as I glue a display, it is always shown twice. plt.ioff() doesn't help.

here is the snippet for displaying image:

def display_image_scrap(nb, key):

    def stringToRGB(base64_string):
        imgdata = base64.b64decode(base64_string)
        image = Image.open(io.BytesIO(imgdata))
        return image
    
    image = stringToRGB(nb.scraps[key].display['data']['image/png'])
    imsize_inches = (np.array(image.size) / 70).astype('int8').tolist()
    
    fig = plt.figure(figsize=imsize_inches)
    ax = fig.add_axes([0, 0, 1, 1])
    ax.imshow(np.array(image), interpolation='antialiased')
    plt.axis('off')

due to (3) I had to disable image scraping for the moment. :(

@MSeal
Copy link
Member

MSeal commented Jan 11, 2021

  • it is not obvious how to display a saved display (image)...

Yeah I'd like to improve the contract here to make it better but still easy to use. Happy to hear suggestions.

  • There is a an unnecessary ambiguity for the word 'display' here. it denotes type of scrap as well as scrap output flag upon saving

This comes from the encoder having the 'display' name as well as the contents of the scrap having a display attribute since the visual is independent of the data that generated said visual. Maybe 'display-only' encoder would be clearer naming convention?

  • as I glue a display, it is always shown twice. plt.ioff() doesn't help.

That sounds like a bug that needs investigating

@willingc willingc added bug Something isn't working docs Documentation labels Apr 28, 2021
@oakaigh
Copy link

oakaigh commented Oct 9, 2023

@MSeal

it is not obvious how to display a saved display (image)...

Since the latest version of matplotlib officially supports pickling, using a pickle-r to encode the whole matplotlib figure could solve the problem. See #91 for implementations and more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working docs Documentation
Projects
None yet
Development

No branches or pull requests

4 participants