Pular para o conteúdo

Python Backend for Cantor: Append Plot Images in Cantor Workspace

Other feature implemented in python backend for Cantor in last weeks was “append plot image to Cantor Workspace”.

In other backends you can, optionally, generate a plot image and this image will be append in Cantor workspace, not generating a separated window to the picture.

Below we have a command to generate a plot image in python using matplotlib and pyplot:


Now we have the result appended in Cantor workspace:

python_plot_resultIn python, to save a picture using pyplot, we type the command pyplot.savefig(). But, if a picture was saved, it can not be shown in separated window. Otherwise, if a picture is shown in a separated window, it can not be saved to a file.

To solve this problem, the python backend change the show() command to savefig(), with a random name to the picture. The image is saved in a temporary file and loaded in Cantor workspace.

The option to load figure in Cantor workspace or to use a separated window is configured in python backend configuration screen. The default is to use separated window because matplotlib/pyplot have several additional features in image screen.

I would like to see some feedback from you, in special if you are a python developer. The code is hosted in python-backend branch from Cantor repository.

2 comentários em “Python Backend for Cantor: Append Plot Images in Cantor Workspace”

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *