plotnine.ggplot
ggplot(data=None, mapping=None)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__(rhs)Add to ggplot
Parameters
other-
Either an object that knows how to “radd” itself to a ggplot, or a list of such objects.
__iadd__
__iadd__(other)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()Show plot using the matplotlib backend set by the user
Users should prefer this method instead of printing or repring the object.
draw
draw(*, show=False)Render the complete plot
Parameters
show : bool = False-
Whether to show the plot.
Returns
Figure-
Matplotlib figure
save
save(
filename=None,
format=None,
path="",
width=None,
height=None,
units="in",
dpi=None,
limitsize=None,
verbose=True,
**kwargs
)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
save_helper(
filename=None,
format=None,
path=None,
width=None,
height=None,
units="in",
dpi=None,
limitsize=None,
verbose=True,
**kwargs
)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.