6
6
import warnings
7
7
8
8
import plotly
9
- from plotly .io ._utils import validate_coerce_fig_to_dict , as_individual_kwargs
9
+ from plotly .io ._utils import validate_coerce_fig_to_dict , as_individual_args
10
10
11
11
ENGINE_SUPPORT_TIMELINE = "September 2025"
12
12
@@ -199,7 +199,7 @@ def to_image(
199
199
"""
200
200
201
201
Kaleido requires Google Chrome to be installed. Install it by running:
202
- $ plotly_install_chrome
202
+ $ plotly_get_chrome
203
203
"""
204
204
)
205
205
@@ -362,7 +362,7 @@ def write_image(
362
362
path .write_bytes (img_data )
363
363
364
364
365
- def to_images (** kwargs ):
365
+ def to_images (* args , * *kwargs ):
366
366
"""
367
367
Convert multiple figures to static images and return a list of image bytes
368
368
@@ -377,18 +377,18 @@ def to_images(**kwargs):
377
377
list of bytes
378
378
The image data
379
379
"""
380
- individual_kwargs = as_individual_kwargs ( ** kwargs )
380
+ individual_args , individual_kwargs = as_individual_args ( * args , ** kwargs )
381
381
382
382
if kaleido_available and kaleido_major > 0 :
383
383
# Kaleido v1
384
384
# TODO: Use a single shared kaleido instance for all images
385
- return [to_image (** kw ) for kw in individual_kwargs ]
385
+ return [to_image (* a , ** kw ) for a , kw in zip ( individual_args , individual_kwargs ) ]
386
386
else :
387
387
# Kaleido v0, or orca
388
- return [to_image (** kw ) for kw in individual_kwargs ]
388
+ return [to_image (* a , ** kw ) for a , kw in zip ( individual_args , individual_kwargs ) ]
389
389
390
390
391
- def write_images (** kwargs ):
391
+ def write_images (* args , * *kwargs ):
392
392
"""
393
393
Write multiple images to files or writeable objects. This is much faster than
394
394
calling write_image() multiple times.
@@ -404,25 +404,18 @@ def write_images(**kwargs):
404
404
None
405
405
"""
406
406
407
- if "file" not in kwargs :
408
- raise ValueError ("'file' argument is required" )
409
-
410
- # Get individual arguments, and separate out the 'file' argument
411
- individual_kwargs = as_individual_kwargs (** kwargs )
412
- files = [kw ["file" ] for kw in individual_kwargs ]
413
- individual_kwargs = [
414
- {k : v for k , v in kw .items () if k != "file" } for kw in individual_kwargs
415
- ]
407
+ # Get individual arguments
408
+ individual_args , individual_kwargs = as_individual_args (* args , ** kwargs )
416
409
417
410
if kaleido_available and kaleido_major > 0 :
418
411
# Kaleido v1
419
412
# TODO: Use a single shared kaleido instance for all images
420
- for f , kw in zip (files , individual_kwargs ):
421
- write_image (file = f , ** kw )
413
+ for a , kw in zip (individual_args , individual_kwargs ):
414
+ write_image (** kw )
422
415
else :
423
416
# Kaleido v0, or orca
424
- for f , kw in zip (files , individual_kwargs ):
425
- write_image (file = f , ** kw )
417
+ for a , kw in zip (individual_args , individual_kwargs ):
418
+ write_image (* a , ** kw )
426
419
427
420
428
421
def full_figure_for_development (fig , warn = True , as_dict = False ):
@@ -494,10 +487,10 @@ def full_figure_for_development(fig, warn=True, as_dict=False):
494
487
return go .Figure (fig , skip_invalid = True )
495
488
496
489
497
- def install_chrome ():
490
+ def get_chrome ():
498
491
"""
499
492
Install Google Chrome for Kaleido
500
- This function can be run from the command line using the command `plotly_install_chrome `
493
+ This function can be run from the command line using the command `plotly_get_chrome `
501
494
defined in pyproject.toml
502
495
"""
503
496
if not kaleido_available or kaleido_major < 1 :
0 commit comments