Skip to content
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

Save to PNG with Top-Level configuration #3617

Open
Amarounek opened this issue Sep 28, 2024 · 2 comments
Open

Save to PNG with Top-Level configuration #3617

Amarounek opened this issue Sep 28, 2024 · 2 comments
Labels

Comments

@Amarounek
Copy link

What happened?

Hey,

I want to save my figure to PNG with a different font but it doesn't seem to work properly.

_weekly_fig_2003

My mini snippet:

combined_chart = alt.layer(bar_year_prec + rule).configure(font='Roboto') 
combined_chart.save(test.png,  ppi = 300)

What would you like to happen instead?

Actually, it is working fine if I don't configure the font overall...

Which version of Altair are you using?

5.4.1

@Amarounek Amarounek added the bug label Sep 28, 2024
@jonmmease
Copy link
Contributor

Hi @Amarounek,

Are you saying that the font specification works if you do it at a lower level, instead of with a top-level configure? Or that setting to Roboto never works?

chart.save uses vl-convert. There is some info on font configuration here https://github.com/vega/vl-convert?tab=readme-ov-file#system-font-requirements.

In particular, if you can locate the directory that contains the Roboto font on your system you can register the fonts with:

import vl_convert as vlc
vlc.register_font_directory('/path/to/roboto')

That said, usually when a font can't be located the chart falls back to using a generic system font, so it's surprising that no text is displayed.

@Amarounek
Copy link
Author

@jonmmease Thanks for your time.

I've tried the lower-level (.configure_axis(labelFont='Arial',) and yes, the targeted aspect also disappeared (Labels). Ok I will tried the vlc register later...

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

No branches or pull requests

2 participants