plotnine.ggplot
Create a new ggplot object
Parameters
Notes
ggplot object only have partial support for pickling. The mappings used by pickled objects should not reference variables in the namespace.
Methods
| Name | Description |
|---|---|
| __add__ | Add to ggplot |
| __iadd__ | Add other to ggplot object |
| show | Show plot using the matplotlib backend set by the user |
| draw | Render the complete plot |
| save | Save a ggplot object as an image file |
| save_helper | Create MPL figure that will be saved |
__add__
Add to ggplot
Parameters
other-
Either an object that knows how to “radd” itself to a ggplot, or a list of such objects.
__iadd__
Add other to ggplot object
Parameters
other : PlotAddable | list[PlotAddable] | None-
Either an object that knows how to “radd” itself to a ggplot, or a list of such objects.
show
Show plot using the matplotlib backend set by the user
This function is called for its side-effects.
draw
Render the complete plot
Parameters
show : bool = False-
Whether to show the plot.
Returns
Figure-
Matplotlib figure
save
Save a ggplot object as an image file
Parameters
filename : Optional[str | Path | BytesIO] = None-
File name to write the plot to. If not specified, a name like “plotnine-save-
. ” is used. format : Optional[str] = None-
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 : Optional[float] = None-
Width (defaults to value set by the theme). If specified the
heightmust also be given. height : Optional[float] = None-
Height (defaults to value set by the theme). If specified the
widthmust also be given. units : str = "in"-
Units for width and height when either one is explicitly specified (in, cm, or mm).
dpi : Optional[int] = None-
DPI to use for raster graphics. If None, defaults to using the
dpiof theme, if none is set then adpiof 100. limitsize : bool | None = None-
If
True(the default), save will not save images larger than 25x25 inches, to prevent the common error of specifying dimensions in pixels. The default value is from the optionplotine.options.limitsize. verbose : bool = True-
If
True, print the saving information. kwargs : Any-
Additional arguments to pass to matplotlib
savefig().
save_helper
Create MPL figure that will be saved
Notes
This method has the same arguments as save. Use it to get access to the figure that will be saved.