From b670902d7cf98cc8298027827c173af005dd1cd3 Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Mon, 29 Jul 2024 14:39:04 +0000 Subject: [PATCH] Tweak plot output appearance --- gui/src/app/Scripting/pyodide/pyodideWorker.ts | 3 ++- gui/src/app/Scripting/webR/runR.ts | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gui/src/app/Scripting/pyodide/pyodideWorker.ts b/gui/src/app/Scripting/pyodide/pyodideWorker.ts index 049e0be2..3c6cce28 100644 --- a/gui/src/app/Scripting/pyodide/pyodideWorker.ts +++ b/gui/src/app/Scripting/pyodide/pyodideWorker.ts @@ -147,7 +147,8 @@ patch_matplotlib(_SP_ADD_IMAGE) postamble += ` import matplotlib.pyplot as plt -plt.show() +if len(plt.gcf().get_children()) > 1: + plt.show() `; } diff --git a/gui/src/app/Scripting/webR/runR.ts b/gui/src/app/Scripting/webR/runR.ts index 9d56ee87..cf5ddaf9 100644 --- a/gui/src/app/Scripting/webR/runR.ts +++ b/gui/src/app/Scripting/webR/runR.ts @@ -30,8 +30,6 @@ const captureOutputOptions = { captureStreams: true, captureConditions: false, captureGraphics: { - width: 340, - height: 340, bg: "white", // default: transparent pointsize: 12, capture: true, @@ -103,6 +101,7 @@ invisible(.SP_DATA)`; // Set canvas size to image canvas.width = img.width; canvas.height = img.height; + canvas.style.width = "100%"; // Draw image onto Canvas const ctx = canvas.getContext("2d");