Skip to content

The Image downloaded using the "download as png" button is distorted #5202

Closed
@FelixBenning

Description

@FelixBenning
import numpy as np
np.random.seed(123)

import plotly.express as px
import plotly.subplots as subplots
from keras.datasets import mnist
# from keras.datasets import fashion_mnist as mnist

(X_train, y_train), (X_test, y_test) =  mnist.load_data()


fig = subplots.make_subplots(rows=2, cols=5)

for n, image in enumerate(X_train[:10]):
  fig.add_trace(px.imshow(255-image).data[0], row=int(n/5)+1, col=n%5+1)


layout = px.imshow(X_train[0], color_continuous_scale='gray').layout
fig.layout.coloraxis = layout.coloraxis
fig.update_xaxes(**layout.xaxis.to_plotly_json())
fig.update_yaxes(**layout.yaxis.to_plotly_json())
fig.show()

this results in this (screenshot):

screenshot

download as png results in this:
download as png

Tangential: It is also way too complicated to generated a small preview selection of pictures. If there is an easier method please answer this stack overflow question

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions