quarto-dev / quarto

Quarto open-source scientific and technical publishing system
https://quarto.org
GNU Affero General Public License v3.0
339 stars 29 forks source link

Quarto does not pick up bytestream images on Mac #183

Closed NickCH-K closed 1 year ago

NickCH-K commented 1 year ago

This is an issue that I originally thought was with Seaborn but after posting the issue there it appears to be with Quarto.

Here's the issue:

  1. I have a Jupyter notebook containing two seaborn.objects graphs. The first one is printed using matplotlib (fig = plt.figure(), then so.Plot().on(fig). The second one is printed using seaborn.objects directly (without .on(fig)). These graphs render properly in Jupyter.
  2. I render that notebook to a document (HTML, Word, PDF, Powerpoint, any of them), using Quarto.
  3. The first graph renders properly in the resulting document. The second one does not appear.
  4. As per the answer to the seaborn issue posted, the seemingly likely issue is that Quarto knows how to pick up the matplotlib rich hooks, but not all hook information.

Note:

  1. This issue occurs only on Mac. I have tested this on two Mac machine and two Windows machines. On both Windows machines, both graphs render properly. On both Macs, only the first renders and the second does not appear. I haven't tested Linux.
  2. This does not produce an error or anything, the graph simply does not appear in the resulting document.
  3. This issue does not occur with non-objects seaborn graphs. sns.lineplot() works fine.
  4. The matplotlib mode (inline or notebook) doesn't seem to matter.
  5. Versions: matplotlib 3.7.1, seaborn 0.12.2. I ran this on my computer Quarto 1.2.269, although some of the other machines I tested on may have been different versions.

Here is the code for a Jupyter notebook that exhibits the issue. Note that I am using p.plot() here, but the same issue occurs if you don't save the plot as p and instead just have so.Plot() on a line by itself.

(code chunk 1, this renders properly on both Windows and Mac)

import pandas as pd
import seaborn.objects as so 
import matplotlib.pyplot as plt

dat = pd.DataFrame({'a':[1,2],'b':[3,4]})

fig = plt.figure()

p = so.Plot(dat, x = 'a', y = 'b').on(fig).add(so.Dot())

p.plot()

(code chunk 2, this does not show up in the resulting document on Mac, but it works fine on Windows)


p = so.Plot(dat, x = 'a', y = 'b').add(so.Dot())

p.plot()
jjallaire commented 1 year ago

Thank you so much for reporting this! This appears to have been a regression in Quarto v1.3 so perhaps you were running v1.3 on Mac on v1.2 on Windows? In any case I reproduced using your test code and verified that the following fixes it and results in the plots showing up as expected: https://github.com/quarto-dev/quarto-cli/commit/27162c0cc93ea639d96f83b6f6f52223069eac71

The fix is on our pre-release v1.4 and we have also back ported the fix to v1.3 stable (available now as v1.3.357) and have

NickCH-K commented 1 year ago

Fantastic, thank you!