matplotlib 3.5.1

ParametersReturns
to_filehandle(fname, flag='r', return_opened=False, encoding=None)

Consider using open_file_cm instead, as it allows one to properly close newly created file objects more easily.

Parameters

fname : str or path-like or file-like

If :None:None:`str` or os.PathLike , the file is opened using the flags specified by flag and encoding. If a file-like object, it is passed through.

flag : str, default: 'r'

Passed as the mode argument to :None:None:`open` when fname is :None:None:`str` or os.PathLike ; ignored if fname is file-like.

return_opened : bool, default: False

If True, return both the file object and a boolean indicating whether this was a new file (that the caller needs to close). If False, return only the new file.

encoding : str or None, default: None

Passed as the mode argument to :None:None:`open` when fname is :None:None:`str` or os.PathLike ; ignored if fname is file-like.

Returns

fh : file-like
opened : bool

opened is only returned if return_opened is True.

Convert a path to an open file handle or pass-through a file-like object.

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /matplotlib/cbook/__init__.py#411
type: <class 'function'>
Commit: