Filipe Saraiva's blog

Tecnologia, sociedade e política.

Python Backend for Cantor: Append Plot Images in Cantor Workspace

with 2 comments

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 Responses to “Python Backend for Cantor: Append Plot Images in Cantor Workspace”

  1. TheBlackCat disse:

    Is there a way to tell cmake which python version to use? It is trying to build against python 3 (and failing).

  2. Thanks for your interest, @TheBlackCat.

    I think it is fixed now, please update your repository. I wrote the code to specify a minimum python version (2.7), but I don’t know if it will prevent the compilation using python3. Please, can you send me a feedback about it?

    You can see the new CMakeLists in

    Thank you.

Leave a Reply to Filipe Saraiva