plotnine.ggplot¶
- class plotnine.ggplot(data: DataLike | None = None, mapping: aes | None = None, environment: EvalEnvironment | None = None)[source]¶
Create a new ggplot object
- Parameters:
- data
dataframe
Default data for plot. Every layer that does not have data of its own will use this one.
- mapping
aes
Default aesthetics mapping for the plot. These will be used by all layers unless specifically overridden.
- environment
EvalEnvironment
If a variable defined in the aesthetic mapping is not found in the data, ggplot will look for it in this namespace. It defaults to using the environment/namespace. in which ggplot() is called.
- data
- save_helper(filename: str | Path | None = None, format: str | None = None, path: str | None = None, width: float | None = None, height: float | None = None, units: str = 'in', dpi: float | None = None, limitsize: bool = True, verbose: bool = True, **kwargs: Any) mpl_save_view [source]¶
Create MPL figure that will be saved
Notes
This method has the same arguments as
ggplot.save()
. Use it to get access to the figure that will be saved.
- save(filename: str | Path | None = None, format: str | None = None, path: str = '', width: float | None = None, height: float | None = None, units: str = 'in', dpi: float | None = None, limitsize: bool = True, verbose: bool = True, **kwargs: Any)[source]¶
Save a ggplot object as an image file
- Parameters:
- filename
str
|pathlib.Path
, optional File name to write the plot to. If not specified, a name like “plotnine-save-<hash>.<format>” is used.
- format
str
Image format to use, automatically extract from file name extension.
- path
str
Path to save plot to (if you just want to set path and not filename).
- width
number
, optional Width (defaults to value set by the theme). If specified the height must also be given.
- height
number
, optional Height (defaults to value set by the theme). If specified the width must also be given.
- units
str
Units for width and height when either one is explicitly specified (in, cm, or mm).
- dpi
float
DPI to use for raster graphics. If None, defaults to using the dpi of theme, if none is set then a dpi of 100.
- limitsizebool
If
True
(the default), ggsave will not save images larger than 50x50 inches, to prevent the common error of specifying dimensions in pixels.- verbosebool
If
True
, print the saving information.- kwargs
dict
Additional arguments to pass to matplotlib savefig().
- filename