graphinglib.Heatmap.from_pdf#
- classmethod Heatmap.from_pdf(path: str, page: int = 0, dpi: float = 200, grayscale: bool = False, x_axis_range: tuple[float, float] | None = None, y_axis_range: tuple[float, float] | None = None, color_map: str | Colormap | Inherit = Inherit, color_map_range: tuple[float, float] | None = None, show_color_bar: bool = True, alpha: float = 1.0, aspect_ratio: str | float | Inherit = Inherit, origin_position: str | Inherit = Inherit, interpolation: str = 'none', norm: str | Normalize | None = None) Self[source]#
Creates a heatmap by rasterizing a page of a PDF file.
This requires the optional
graphinglib[pdf]extra (installspypdfium2).- Parameters:
- pathstr
Path to the PDF file to open.
- pageint
Index of the page to rasterize. Defaults to
0.- dpifloat
Resolution used to rasterize the page, in dots per inch. Defaults to
200.- grayscalebool
Whether to rasterize the page directly to a single-channel grayscale array, so that
color_mapis applied to it like a regular data heatmap. WhenFalse, the page is kept as an RGB image, matching howHeatmapalready displays other image file formats; in that case,color_mapandshow_color_barhave no effect, since an RGB image never gets a color bar (same behavior as loading any other image file). Defaults toFalse.- x_axis_range, y_axis_rangetuple[float, float], optional
The range of x and y values used for the axes as tuples containing the start and end of the range.
- color_mapstr, Colormap
The color map to use for the
Heatmap. Only has an effect whengrayscaleisTrue. Can either be specified as a string (named colormap from Matplotlib) or a Colormap object. Examples include"viridis","plasma", and"coolwarm". Defaults to"gray"whengrayscaleisTrue; otherwise, default depends on thefigure_styleconfiguration.- color_map_range: tuple[float, float], optional
The data range covered by the color map, given as
(minimum, maximum).- show_color_barbool
Whether or not to display the color bar next to the plot. Only has an effect when
grayscaleisTrue. Defaults toTrue.- alphafloat
Opacity value of the
Heatmap. Range is0(transparent) to1(opaque). Defaults to 1.0.- aspect_ratiostr or float
Aspect ratio of the axes. Values include
"auto","equal", or a positive float. Default depends on thefigure_styleconfiguration.- origin_positionstr
Position of the origin of the axes (upper left or lower left corner). Values are
"upper"and"lower". Default depends on thefigure_styleconfiguration.- interpolationstr
Interpolation method to be applied to the image. Values include
"none","nearest","bilinear","bicubic","spline16","spline36","hanning","hamming","hermite","kaiser","quadric","catrom","gaussian","bessel","mitchell","sinc", and"lanczos". Defaults to"none".See also
For other interpolation methods, refer to Interpolations for imshow.
- normstr or Normalize, optional
Normalization of the colormap. Default is
None.
- Returns:
- A
Heatmapobject created from a page of a PDF file.
- A