quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.92k stars 324 forks source link

Plot embedded from Jupyter notebook is not scaled correctly in LaTeX pdf output #10520

Open ondrej-such opened 2 months ago

ondrej-such commented 2 months ago

Bug description

In newest version of Quarto (1.5) an R plot from Jupyter notebook is not scaled correctly - it runs beyond the right margin of the page.

Steps to reproduce

---
title: "Test"
format:
  pdf:
    documentclass: scrreprt
---

{{< embed test1.ipynb#plot1 >}}

In the notebook there are two cells:

The first one is:

options(repr.plot.res = 600, repr.plot.width = 5.5, repr.plot.height = 2.5)

The second one is:

#| label: plot1
#| fig-cap: Plot of 10 points
plot(1:10, 1:10)

Expected behavior

In older versions of quarto (1.3 and I believe also 1.4) the image was scaled properly, so it fit within the margins.

Actual behavior

The image goes past the right margin.

Your environment

Windows 11

Quarto check output

C:\Users\Ondrej\Desktop\mlbook>quarto check Quarto 1.5.56 [>] Checking versions of quarto binary dependencies... Pandoc version 3.2.0: OK Dart Sass version 1.70.0: OK Deno version 1.41.0: OK Typst version 0.11.0: OK [>] Checking versions of quarto dependencies......OK [>] Checking Quarto installation......OK Version: 1.5.56 Path: C:\Users\Ondrej\AppData\Local\Programs\Quarto\bin CodePage: 1252

[>] Checking tools....................OK TinyTeX: v2023.09 Chromium: 869685

[>] Checking LaTeX....................OK Using: TinyTex Path: C:\Users\Ondrej\AppData\Roaming\TinyTeX\bin\windows\ Version: 2023

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....(None)

  Unable to locate an installed version of Python 3.
  Install Python 3 from https://www.python.org/downloads/

[>] Checking R installation...........OK Version: 4.4.1 Path: C:/PROGRA~1/R/R-44~1.1 LibPaths:

[>] Checking Knitr engine render......OK

mcanouil commented 2 months ago

Could you properly format your post using code blocks for code and terminal outputs? Thanks. If your code contains code blocks, you need to enclose it using more backticks, i.e., usually four ````. See https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us.

ondrej-such commented 2 months ago

I tried my best. As far as I can tell, there is no quoting convention for Jupyter notebooks. Also, the bug report webpage did not allow me to upload a Jupyter notebook, so the contents of its cells are described in words.

mcanouil commented 2 months ago

It was for the code cells as plain text.

You cannot upload Jupyter Notebook because of security setup on GitHub. Executable files are also not allowed for instance.

Note that Jupyter Notebook are JSON, and JSON can be pasted as plain text (no upload thus download needed).

mcanouil commented 2 months ago

Still, your Jupyter Notebook with R code cells requires special setup for us to use. If we can't execute the Jupyter Notebook with the cells, we can't reproduce any of your report.

What's the purpose of?

options(repr.plot.res = 600, repr.plot.width = 5.5, repr.plot.height = 2.5)

Maybe the easiest would be for you to share a Git repository with a small example to reproduce the issue.

ondrej-such commented 2 months ago

I created a github repo

https://github.com/ondrej-such/Bug10520

The purpose of setting the options is to create a higher (600 DPI ) resolution plot of a given size.

ondrej-such commented 2 months ago

Hello Mickael,

the bug lingers on github with missing repro status, but I added already a repository for easy repro.

Should I do anything else to help you find the root cause?

Best regards, -Ondrej

št 15. 8. 2024 o 11:58 Mickaël Canouil @.***> napísal(a):

Still, your Jupyter Notebook with R code cells requires special setup for us to use. If we can't execute the Jupyter Notebook with the cells, we can't reproduce any of your report.

What's the purpose of?

options(repr.plot.res = 600, repr.plot.width = 5.5, repr.plot.height = 2.5)

— Reply to this email directly, view it on GitHub https://github.com/quarto-dev/quarto-cli/issues/10520#issuecomment-2291001855, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE63IC2P3QICUZSUSGNUDLDZRR3WDAVCNFSM6AAAAABMR3A27KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJRGAYDCOBVGU . You are receiving this because you authored the thread.Message ID: @.***>

github-actions[bot] commented 2 months ago

Thank you for using Quarto and reporting an issue!

Unfortunately, this issue is now considered stale because it has been opened since 14 days without providing a "working" reproducible example to help us investigate. If you are still facing the issue, please review the "Bug Reports" guide on how to provide a fully reproducible example as a self-contained Quarto document or a link to a Git repository. Without a reproducible example, it is unlikely that the issue will be addressed.

You can share a Quarto document using the following syntax, i.e., using more backticks than you have in your document (usually four ````).

````qmd
---
title: "Reproducible Quarto Document"
format: html
---

This is a reproducible Quarto document using `format: html`.
It is written in Markdown and contains embedded R code.
When you run the code, it will produce a plot.

```{r}
plot(cars)

The end.

ondrej-such commented 2 months ago

Simple repro scenario was added 3 weeks ago as giyhub repository

https://github.com/ondrej-such/Bug10520