{"id":1141,"date":"2013-09-16T14:57:18","date_gmt":"2013-09-16T14:57:18","guid":{"rendered":"http:\/\/blog.filipesaraiva.info\/?p=1141"},"modified":"2013-12-28T17:21:34","modified_gmt":"2013-12-28T17:21:34","slug":"python-backend-for-cantor-append-plot-images-in-cantor-workspace","status":"publish","type":"post","link":"https:\/\/filipe.saraiva.tec.br\/blog\/?p=1141","title":{"rendered":"Python Backend for Cantor: Append Plot Images in Cantor Workspace"},"content":{"rendered":"<p style=\"text-align: justify;\">Other feature implemented in python backend for Cantor in last weeks was &#8220;append plot image to Cantor Workspace&#8221;.<\/p>\n<p style=\"text-align: justify;\">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.<\/p>\n<p style=\"text-align: justify;\">Below we have a command to generate a plot image in python using matplotlib and pyplot:<\/p>\n<p><a href=\"http:\/\/blog.filipesaraiva.info\/wp-content\/uploads\/2013\/09\/python_command_to_plot.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1143\" data-permalink=\"https:\/\/filipe.saraiva.tec.br\/blog\/?attachment_id=1143\" data-orig-file=\"https:\/\/filipe.saraiva.tec.br\/blog\/wp-content\/uploads\/2013\/09\/python_command_to_plot.png\" data-orig-size=\"1366,737\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"python_command_to_plot\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/filipe.saraiva.tec.br\/blog\/wp-content\/uploads\/2013\/09\/python_command_to_plot-300x161.png\" data-large-file=\"https:\/\/filipe.saraiva.tec.br\/blog\/wp-content\/uploads\/2013\/09\/python_command_to_plot-1024x552.png\" class=\"aligncenter size-large wp-image-1143\" alt=\"python_command_to_plot\" src=\"http:\/\/blog.filipesaraiva.info\/wp-content\/uploads\/2013\/09\/python_command_to_plot-1024x552.png\" width=\"698\" height=\"375\" srcset=\"https:\/\/filipe.saraiva.tec.br\/blog\/wp-content\/uploads\/2013\/09\/python_command_to_plot-1024x552.png 1024w, https:\/\/filipe.saraiva.tec.br\/blog\/wp-content\/uploads\/2013\/09\/python_command_to_plot-300x161.png 300w\" sizes=\"auto, (max-width: 698px) 100vw, 698px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">Now we have the result appended in Cantor workspace:<\/p>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/blog.filipesaraiva.info\/wp-content\/uploads\/2013\/09\/python_plot_result.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1142\" data-permalink=\"https:\/\/filipe.saraiva.tec.br\/blog\/?attachment_id=1142\" data-orig-file=\"https:\/\/filipe.saraiva.tec.br\/blog\/wp-content\/uploads\/2013\/09\/python_plot_result.png\" data-orig-size=\"1366,737\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"python_plot_result\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/filipe.saraiva.tec.br\/blog\/wp-content\/uploads\/2013\/09\/python_plot_result-300x161.png\" data-large-file=\"https:\/\/filipe.saraiva.tec.br\/blog\/wp-content\/uploads\/2013\/09\/python_plot_result-1024x552.png\" class=\"aligncenter size-large wp-image-1142\" alt=\"python_plot_result\" src=\"http:\/\/blog.filipesaraiva.info\/wp-content\/uploads\/2013\/09\/python_plot_result-1024x552.png\" width=\"698\" height=\"375\" srcset=\"https:\/\/filipe.saraiva.tec.br\/blog\/wp-content\/uploads\/2013\/09\/python_plot_result-1024x552.png 1024w, https:\/\/filipe.saraiva.tec.br\/blog\/wp-content\/uploads\/2013\/09\/python_plot_result-300x161.png 300w\" sizes=\"auto, (max-width: 698px) 100vw, 698px\" \/><\/a>In python, to save a picture using pyplot, we type the command <em>pyplot.savefig()<\/em>. 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.<\/p>\n<p style=\"text-align: justify;\">To solve this problem, the python backend change the <em>show() <\/em>command to <em>savefig()<\/em>, with a random name to the picture. The image is saved in a temporary file and loaded in Cantor workspace.<\/p>\n<p style=\"text-align: justify;\">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.<\/p>\n<p style=\"text-align: justify;\">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 <a href=\"https:\/\/projects.kde.org\/projects\/kde\/kdeedu\/cantor\/repository\/\" target=\"_blank\">Cantor repository<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Other feature implemented in python backend for Cantor in last weeks was &#8220;append plot image to Cantor Workspace&#8221;. 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&hellip;&nbsp;<a href=\"https:\/\/filipe.saraiva.tec.br\/blog\/?p=1141\" class=\"\" rel=\"bookmark\">Continue a ler &raquo;<span class=\"screen-reader-text\">Python Backend for Cantor: Append Plot Images in Cantor Workspace<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[9],"tags":[58,48,11,47,101,26,51,109,104,41,52,108,80],"class_list":["post-1141","post","type-post","status-publish","format-standard","hentry","category-software-livre","tag-cantor","tag-comunidade","tag-desenvolvimento","tag-gsoc","tag-gsoc2013-python-backend","tag-kde","tag-planet-mageia-english","tag-planet-python","tag-planet-scipy","tag-planeta-psl-pi","tag-planetkde-english","tag-python","tag-python-backend"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1p2Jh-ip","jetpack_sharing_enabled":true,"jetpack_likes_enabled":false,"_links":{"self":[{"href":"https:\/\/filipe.saraiva.tec.br\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/filipe.saraiva.tec.br\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/filipe.saraiva.tec.br\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/filipe.saraiva.tec.br\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/filipe.saraiva.tec.br\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1141"}],"version-history":[{"count":1,"href":"https:\/\/filipe.saraiva.tec.br\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1141\/revisions"}],"predecessor-version":[{"id":1144,"href":"https:\/\/filipe.saraiva.tec.br\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1141\/revisions\/1144"}],"wp:attachment":[{"href":"https:\/\/filipe.saraiva.tec.br\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/filipe.saraiva.tec.br\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/filipe.saraiva.tec.br\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}