Skip to content

In latest version, figure size is too big even if I use "dpi=800, fontsize=3.8" #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yun881201 opened this issue Jan 11, 2024 · 4 comments

Comments

@yun881201
Copy link

yun881201 commented Jan 11, 2024

Hello.
I recently reinstalled dataframe-image.
However, unlike before, even if "dpi=800, fontsize=3.8" code is used, the image size cannot be reduced while maintaining good image quality.
How can I do this?

@PaleNeutron
Copy link
Collaborator

Can you provide a minimal reproduce example?

@yun881201
Copy link
Author

yun881201 commented Jan 12, 2024

Chrome : 120.0.6099.217
jupyter-book : 0.15.1
dataframe-image : 0.2.3

The followings are cells written in the testing jupyter notebook and I converted the notebook to a latex pdf by using jupyter-book. I attached the resulted pdf file. As you can see, the figures in the pdf are all too big or have bad quality.
_val.pdf

cell1 : code cell

import pandas as pd
import dataframe_image as dfi

cell2 : code cell

data = {'Name': ['Tom', 'nick', 'krish', 'jack'],
'Age': [20, 21, 19, 18]}
df = pd.DataFrame(data)
df

cell3 : code cell

figname = 'test'
dfi.export(df, 'figure/{}.png'.format(figname))

cell4 : md cell
![test](figure/test.png)

cell5 : code cell

figname = 'test1'
dfi.export(df, 'figure/{}.png'.format(figname), fontsize=3.8, dpi=800)#, fontsize=12)#, fontsize=4, dpi=800)

cell6 : md cell
![test1](figure/test1.png)

cell7 : code cell

figname = 'test2'
dfi.export(df, 'figure/{}.png'.format(figname), fontsize=1, dpi=800)

cell8 : md cell
![test1](figure/test2.png)

cell9 : code cell

figname = 'test3'
dfi.export(df, 'figure/{}.png'.format(figname), dpi=70)

cell10: md cell
![test1](figure/test3.png)

@PaleNeutron
Copy link
Collaborator

High dpi and very small fontsize is used in early version which adopt a bug in Chrome version 111. And I have tried your code with version 0.1.12 it looks like the same.

I think you should export image with dpi 300 and resize it as documented in https://jupyterbook.org/en/stable/content/figures.html

@yun881201
Copy link
Author

yun881201 commented Feb 7, 2024

Based on PaleNeutron comment, I solved my problem.
I used the following code:
For dpi 300,

```{image} figure/filename.png
:scale: 19%
:name: filename
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants