plotnine.ggplot
=None, mapping=None) ggplot(data
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 from a list |
__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__(other)
Add to ggplot from a list
Parameters
other : PlotAddable | list[PlotAddable] | None
-
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
=False) draw(show
Render the complete plot
Parameters
show : bool = False
-
Whether to show the plot.
Returns
Figure
-
Matplotlib figure
save
save(=None,
filenameformat=None,
="",
path=None,
width=None,
height="in",
units=None,
dpi=None,
limitsize=True,
verbose={}
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
height
must also be given. height : Optional[float] = None
-
Height (defaults to value set by the theme). If specified the
width
must 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
dpi
of theme, if none is set then adpi
of 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(=None,
filenameformat=None,
=None,
path=None,
width=None,
height="in",
units=None,
dpi=None,
limitsize=True,
verbose={}
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.