enable assignment of "Download plot as a png" value to variable
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 18.8k
- Forks
- 2.8k
- Merge médio
- 16h 26min
- PRs com merge (30d)
- 21
Descrição
Bug (or Feature Request?):
I want to get the annotated image after I used drawrect. The only possible way, for now, is using the Download plot as a png button, save it on pc, read it. Is there a straightforward way to do that?
I mark it as a bug (or maybe it's the intended behavior by the developer) because fig.to_image(format="png", engine="kaleido") return the original image, not the annotated one.
Note: I'm using a jupyter notebook
import plotly.graph_objects as go
fig = go.Figure(data=go.Bar(y=[2, 3, 1]))
config = dict({
'modeBarButtonsToAdd':[
'drawrect',
'eraseshape',
],
'modeBarButtonsToRemove':[
'toggleSpikelines','hoverCompareCartesian'
]
})
fig.show(config=config)

do some annotations...

then run:
import numpy as np
import cv2
import matplotlib.pyplot as plt
annotate_image = fig.to_image(format="png", engine="kaleido")
nparr = np.frombuffer(annotate_image, np.uint8)
img_numpy = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
plt.imshow(img_numpy[...,::-1])

The plt.imshow(img_numpy[...,::-1]) will show the original image, not the annotated image. How to use fig.to_image(format="png", engine="kaleido") to include the annotation of drawrect? Or any workaourd?
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece pelo ponto de entrada fig.show(config=config) e pela interação drawrect, depois compare-os com fig.to_image(format="png", engine="kaleido"). Determine se o estado anotado pode ser passado pelo caminho de exportação existente; considera-se concluído quando a imagem atribuída resultante inclui o retângulo desenhado. Nenhum arquivo do repositório ou teste é mencionado na issue.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- jupyter-notebook, python
- Domínio
- data-visualization
- Tipo de issue
- Funcionalidade
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100