You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created a chart specification that renders perfectly in my notebook. I can then right-click, save to PNG, and get what I need. The full expected visualization (using the entire dataset) is as follows:
If I attempt to temps.save("temps.png") I get an error about the Vega-Lite to PNG conversion failing:
---------------------------------------------------------------------------ValueErrorTraceback (mostrecentcalllast)
CellIn[138], line1---->1temps.save("temps.png")
File [~/miniconda3/envs/ttemp/lib/python3.12/site-packages/altair/vegalite/v5/api.py:2092](http://localhost:8888/lab/tree/~/miniconda3/envs/ttemp/lib/python3.12/site-packages/altair/vegalite/v5/api.py#line=2091), in TopLevelMixin.save(self, fp, format, override_data_transformer, scale_factor, mode, vegalite_version, vega_version, vegaembed_version, embed_options, json_kwds, engine, inline, **kwargs)2090ifoverride_data_transformer:
2091withdata_transformers.disable_max_rows():
->2092save(**kwds)
2093else:
2094save(**kwds)
File [~/miniconda3/envs/ttemp/lib/python3.12/site-packages/altair/utils/save.py:224](http://localhost:8888/lab/tree/~/miniconda3/envs/ttemp/lib/python3.12/site-packages/altair/utils/save.py#line=223), in save(chart, fp, vega_version, vegaembed_version, format, mode, vegalite_version, embed_options, json_kwds, scale_factor, engine, inline, **kwargs)217else:
218# Temporarily turn off any data transformers so that all data is inlined219# when calling chart.to_dict. This is relevant for vl-convert which cannot access220# local json files which could be created by a json data transformer. Furthermore,221# we don't exit the with statement until this function completed due to the issue222# described at https://github.com/vega/vl-convert/issues/31223withdata_transformers.enable("default"), data_transformers.disable_max_rows():
-->224perform_save()
File~/miniconda3/envs/ttemp/lib/python3.12/site-packages/altair/utils/save.py:175, insave.<locals>.perform_save()
171write_file_or_filename(
172fp, mb_html["text/html"], mode="w", encoding=encoding173 )
174elifformat=="png":
-->175mb_png=spec_to_mimebundle(
176spec=spec,
177format=format,
178mode=inner_mode,
179vega_version=vega_version,
180vegalite_version=vegalite_version,
181vegaembed_version=vegaembed_version,
182embed_options=embed_options,
183scale_factor=scale_factor,
184engine=engine,
185**kwargs,
186 )
187write_file_or_filename(fp, mb_png[0]["image/png"], mode="wb")
188elifformatin {"svg", "pdf", "vega"}:
File [~/miniconda3/envs/ttemp/lib/python3.12/site-packages/altair/utils/mimebundle.py:134](http://localhost:8888/lab/tree/~/miniconda3/envs/ttemp/lib/python3.12/site-packages/altair/utils/mimebundle.py#line=133), in spec_to_mimebundle(spec, format, mode, vega_version, vegaembed_version, vegalite_version, embed_options, engine, **kwargs)131embed_options=preprocess_embed_options(final_embed_options)
133ifformatin {"png", "svg", "pdf", "vega"}:
-->134return_spec_to_mimebundle_with_engine(
135spec,
136cast(Literal["png", "svg", "pdf", "vega"], format),
137internal_mode,
138engine=engine,
139format_locale=embed_options.get("formatLocale", None),
140time_format_locale=embed_options.get("timeFormatLocale", None),
141**kwargs,
142 )
143elifformat=="html":
144html=spec_to_html(
145spec,
146mode=internal_mode,
(...)
151**kwargs,
152 )
File [~/miniconda3/envs/ttemp/lib/python3.12/site-packages/altair/utils/mimebundle.py:244](http://localhost:8888/lab/tree/~/miniconda3/envs/ttemp/lib/python3.12/site-packages/altair/utils/mimebundle.py#line=243), in _spec_to_mimebundle_with_engine(spec, format, mode, format_locale, time_format_locale, **kwargs)236png=vlc.vega_to_png(
237spec,
238scale=scale,
(...)
241time_format_locale=time_format_locale,
242 )
243else:
-->244png=vlc.vegalite_to_png(
245spec,
246vl_version=vl_version,
247scale=scale,
248ppi=ppi,
249format_locale=format_locale,
250time_format_locale=time_format_locale,
251 )
252factor=ppi/default_ppi253w, h=_pngxy(png)
ValueError: Vega-LitetoPNGconversionfailed:
Error: Expressionparseerror: ("Video time (m's\"): "+ (timeFormat(datum["datetime"], '%M'%S"')) + "; Temp, °C: " + (format(datum["temp"], "")) + "; roi: " + (isValid(datum["roi"]) ? datum["roi"] : ""+datum["roi"]) + "; Frame: " + (isValid(datum["frameId"]) ? datum["frameId"] : ""+datum["frameId"]) + "; VideoTime: " + (isValid(datum["time_label"]) ? datum["time_label"] : ""+datum["time_label"]) + "; Temp (°C): " + (format(datum["temp"], ".2f")) + "; ROI: " + (isValid(datum["roi"]) ? datum["roi"] : ""+datum["roi"]) + "; xy: " + (isValid(datum["xy"]) ? datum["xy"] : ""+datum["xy"]))
atb (https://cdn.skypack.dev/-/vega-util@v1.17.2-LUfkDhormMyfWqy3Ts6U/dist=es2020,mode=imports,min/optimized/vega-util.js:1:324)
atRn (https://cdn.skypack.dev/-/vega-functions@v5.15.0-Bjrw9nnQutKMtsMi1DSI/dist=es2020,mode=imports,min/optimized/vega-functions.js:1:12384)
atBn (https://cdn.skypack.dev/-/vega-parser@v6.4.0-nwGMLAa2L4N1N7f1iRh9/dist=es2020,mode=imports,min/optimized/vega-parser.js:1:4443)
atAn (https://cdn.skypack.dev/-/vega-parser@v6.4.0-nwGMLAa2L4N1N7f1iRh9/dist=es2020,mode=imports,min/optimized/vega-parser.js:1:4271)
atze (https://cdn.skypack.dev/-/vega-parser@v6.4.0-nwGMLAa2L4N1N7f1iRh9/dist=es2020,mode=imports,min/optimized/vega-parser.js:1:4175)
atMt (https://cdn.skypack.dev/-/vega-parser@v6.4.0-nwGMLAa2L4N1N7f1iRh9/dist=es2020,mode=imports,min/optimized/vega-parser.js:1:24664)
athttps://cdn.skypack.dev/-/vega-parser@v6.4.0-nwGMLAa2L4N1N7f1iRh9/dist=es2020,mode=imports,min/optimized/vega-parser.js:1:39141atArray.forEach (<anonymous>)
athn (https://cdn.skypack.dev/-/vega-parser@v6.4.0-nwGMLAa2L4N1N7f1iRh9/dist=es2020,mode=imports,min/optimized/vega-parser.js:1:39130)
atal (https://cdn.skypack.dev/-/vega-parser@v6.4.0-nwGMLAa2L4N1N7f1iRh9/dist=es2020,mode=imports,min/optimized/vega-parser.js:1:39804)
The most relevant part of which appears to be this expression:
Have confirmed that resorting to unicode strings to pass the spec in generates an acceptable in-notebook visual, but does not pass the compilation process:
...
alt.X("datetime:T",
axis=alt.Axis(format="%M\u0027%S\u0022", tickColor="red", gridColor="#EEE"),
).title("Video time (m\u0027s\u0022)"),
...
What happened?
I have created a chart specification that renders perfectly in my notebook. I can then right-click, save to PNG, and get what I need. The full expected visualization (using the entire dataset) is as follows:
If I attempt to
temps.save("temps.png")
I get an error about the Vega-Lite to PNG conversion failing:The most relevant part of which appears to be this expression:
The output of
pprint.pprint(temps.to_dict())
is as follows:Here's a reduced dataset that reproduces the problem:
MWE
The outcome is as follows:
The result of
mwe.save("temps_test.png")
remains the same as with the full dataset:What would you like to happen instead?
No response
Which version of Altair are you using?
5.4.1
The text was updated successfully, but these errors were encountered: