Changelog
v0.15.0
(2025-06-15)
API Changes
Themeables
axis_ticks_pad,axis_ticks_pad_minor,axis_ticks_pad_major,axis_ticks_pad_minor_x,axis_ticks_pad_minor_y,axis_ticks_pad_major_xandaxis_ticks_pad_major_yhave been deprecated. Use themarginparameter ofelement_textwithaxis_text,axis_text_xoraxis_text_yto control the spacing between the axis text and the ticks. (#843)The
statclass methodsstat.compute_layer,stat.compute_panelandstat.compute_groupare now instance methods and they no longer accept**paramsarguments. Access to the parameters is throughself.params.The
geomclass methodsgeom.draw_layerandgeom.draw_paneldo no longer accept**paramarguments. Access to the parameters is throughself.params.Method
geom.draw_groupnow accepts theparamsargument as a dictionary and not**params.
New Features
Plot Composition is here. Using an intuitive algebra, you can now put combine multiple plots into a single graphic. e.g.
p1 = ggplot(...) p2 = ggplot(...) p3 = ggplot(...) (p1 | p2) / p3Using
plot_title_positionandplot_caption_positione.g.theme( plot_title_position="plot", plot_caption_position="plot", )You can now position the
plot_title,plot_subtitleandplot_captionby alignment them with respect to the plot. (#838)Gained new label
tagto create a tag for a plot. You can set it withlabse.g.labs(tag="A")and customise it using these themeables
plot_tagandplot_tag_positionandplot_tag_locatione.g.
theme( plot_tag="plot", plot_tag_location="plot", plot_tag_position="topright", )Geoms
geom_barandgeom_colhave gained new parameterjustthat controls how the bars align with the axis break point.geom_sinahas gained new parameterstylejust likegeom_violin, which make one-sided (half) sina plots.Gained the Anscombe Quartet dataset,
anscombe_quartet.Gained new module
plotnine.helpersto be a place for some helper functions.Gained new helper function
get_aesthetic_limits.geom_pointgained the ability to handle shapes of the formSequence[tuple[float, float]]e.g.((-2, -4), (-2, -1), (0, 1), (2, -1), (2, -4), (-2, -4))Which declares the vertices of a polygon shape.
Enhancements
Included datasets
mpg,msleepandmidwestno longer have any of their columns as categoricals. This matches the respective datasets in R. (#913)When the
widthof the violins ingeom_violinis wider than their normal area, they now overlap with those closest to the origin on top. This makes it possible to create overlapping ridge plots using half violins.legend_keynow inherits frompanel_backgroundand the default themes have been adjusted to rely on this inheritance. So when using the default themes, alteringfillparameter of thepanel_backgroundwill also affect the background of thelegend_key.The default value for the
guideparameter for the identity scales (scale_*_identity) has been reverted toNone. This means by default using these scales will not generate a legend.
Bug Fixes
Fixed bug in with the
legend_key_heightthemeable where it wasn’t applied. (#921)Fixed bug where justifying
axis_text_xandaxis_text_yusing horizontal and vertical alignment did not work as expected. (#927)Fixed justifying strip_text within the strip_background. (#867)
Fixed bug where facetting along a column with unused categories could raise an error. (#930)
Fixed bug where computed aesthetic from
after_scaleare were not applied to the legend. (#926)Fixed theming of minor x axis ticks.
Fixed theming of
axis_text,axis_text_xandaxis_text_yso when they can be overriden if previously set toelement_blank().Fixed
strip_text_x_backgrounds to always have equal heights andstrip_text_y_backgrounds to have equal widths. This applies to cases where the texts have unequal number of lines or they are rotated but have different lengths.Fixed the empty space below the plot title (or subtitle) when
strip_text_x_backgrounds are partly or fully aligned within the panel. This space (hole), was not accounted for by any of the themeables. This affectedtheme_xkcdand anythemesettings that tried to slide the text / background into the panel.Fixed the empty space to the left the right margin when the
strip_text_y_backgrounds are partly or fully aligned within the panel. This space (hole), was not accounted for by any of the themeables. This affectedtheme_xkcdand anythemesettings that tried to slide the text / background into the panel.Fixed bug in
geom_histogramwhere mapping to theweightaesthetic lead to an error. (#936)Fixed bug in
geom_vlinewhere you could not map thexinterceptaesthetic to a discrete variable.Fixed bug in
geom_hlinewhere you could not map theyinterceptaesthetic to a discrete variable.Fixed bug in all manual scales (
scale_*_manual) where if you setvaluesto adictthen setting the breaks would lead to an error. (#949)Fixed using
theme_voidwith facetting so that the strip text are always fully within the figure bounds.Fixed the ordinal color scales
scale_color_ordinal,scale_color_cmap_dscale_fill_ordinalandscale_fill_cmap_dto handle missing (NaNorNone) values. (#953)
v0.14.5
- Fixed
geom_textwithadjust_textso that the the arrows are drawn between layers with the text/label on top.
v0.14.4
Bug Fixes
Fixed
geom_textwithadjust_textso that the the arrows are drawn at the same layer (zorder) as the text.Fixed
geom_textwithadjust_textfor some cases where the text are placed outside the panels. (#899)The default aesthetics and aesthetic parameters of geoms (and stats) are now transformed. So you can now set date values as aesthetic parameters. e.g.
geom_point(y=datetime(2024, 12, 11))if the
yaesthetic is mapped to datetime column in another layer.Fixed bug for matplotlib>3.10 where the
axis_ticks_lengthfor the x-axis had no effect.
v0.14.3
Enhancements
Got rid of a logging information about the fontsize that is recorded for all plots that have a legend. (#889)
When using
geom_textwithadjust_text, some sensible default arrow properties will be applied.Changed the threshold number of keys for when the legend is split into multiple columns from 20 to 15. This only applies in the default case when the user does not set the number of rows or columns i.e.
guide_legend(nrow=None, ncol=None). (#757)
v0.14.2
(2024-11-21)
Bug Fixes
Fixed bugs that affected
geom_dotplotandgeom_sinawhere data with an index that did not include 0 led to a crash. (#888)Fixed
v0.14.0regression that madescale_color_cmap_dunusable. (#890)
v0.14.1
(2024-11-05)
Bug Fixes
Fix expansion of datetime and timedelta scales when using both the lower and upper addition constants.
In quarto documents make the output
retinaeven if thefig-formatispng.Fixed bug where you could not save as pdf if also specifying the
aspect_ratio. (#885)
v0.14.0
(2024-10-28)
API Changes
You cannot call
printon a ggplot object to show it. This was deprecated inv0.13.0and it has now been removed. Use ggplot.show()The color_space parameter of
scale_color_huenow accepts the value"hlsuv"instead of"husl". The meaning of has not changed, and"husl"is silently accepted.Themeables
axis_ticks_direction,axis_ticks_direction_xandaxis_ticks_direction_yhave be deprecated. In their place, the direction of the ticks can be controlled by using +ve, -ve or complex values for theaxis_ticks_length,axis_ticks_length_major,axis_ticks_length_major_x,axis_ticks_length_major_y,axis_ticks_length_minor,axis_ticks_length_minor_x, oraxis_ticks_length_minor_y.
Enhancements
The
family,fontstyleandfontweightparameters ofgeom_textare now aesthetics (#790).plotnine now responds to the
fig-width,fig-heightandfig-formatsettings in the meta section of a quarto document.ggtitlenow acceptstitleandsubtitleas keyword arguments. (#804)Gained the option
limitsizethat makes it possible to display plots of any size.from plotnine.options import set_option set_option("figure_format", False)For
geom_boxplotwhen the outliers are made invisible by giving them no shape, now they do not affect the limits of the plot. (#814)Made it possile to map an aesthetic value to
None. (#791)The signatures for the scale classes now list all the allowed parameters.
New Features
geom_texthas gained new aestheticsfontvariantandfontstretch.
Bug Fixes
Fix layers 3 and above not to overlap the axis lines if there are any (#798).
Fixed bug in
geom_segmentwhere the lineend parameter was ignored. (#727)Fixed
stat_summary_binto work with continuousxaesthetic when specifying thebinwidthorbreaks. (#824)Fixed
PlotnineAnimationnot to draw a second legend at the bottom-left corner. (#816)Fixed bug where setting
theme(text=element_blank())would raise and exception.Fixed
datetimeandtimedeltascales so they can be expanded by adding constanttimedeltavalues.
v0.13.6
(2024-05-09)
Bug Fixes
- Fixed
geom_labelto work with aboxstyleof any followingsquare,circle,darrow,larrow,rarrow,roundtoothorsawtooth.(#779)
Enhancements
Stopped spurious warnings of the form
PlotnineWarning: Failed to apply `after_scale` modifications to the legend.when theafter_scalemapping is for another aestetic.Added
widthandheightas default aesthetics ofgeom_tile.
v0.13.5
(2024-04-26)
Bug Fixes
Fixed bug in
stat_smoothwhere you could not set the family when using aglm. (#769)Fixed bug in
position_dodge2the widths of the dodged objects were mixed up. (#772)Fixed
geom_textto work better with adjustTextv1.0.0and above.Fixed images generated in quarto so that they have the dimensions (taking the dpi into account) that are specified in theme. (#773)
New
- Added themeable
svg_usefonts. (#756)
Enhancements
- Added palmerpenguins dataset.
v0.13.4
(2024-04-03)
Bug Fixes
- Fixed regression in v0.13.3 where setting some text elements
element_blankled to an error. (#764)
v0.13.3
Bug Fixes
Fixed layout manager to make space for the
strip_textwhen there is nostrip_background. (#760)Made the default position of
guide_legendtext to be right. (#761)Fixed aligning (
ha&va) ofplot_title,plot_subtitle,plot_caption,axis_title_x,axis_title_yto work with float values in the range[0, 1].
v0.13.2
(2024-03-14)
Enhancements
- Drawing the plot ensures that pandas Copy-on-Write is turned off. Plotnine is not yet compatible with Copy-on-Write so this prevents errors for users who have turned on the option.
v0.13.1
(2024-03-06)
Bug Fixes
Fixed a bug where a legend with blank title or text could result in a wrong justification.
Fixed a bug where setting legend justification to a string i.e one of
left,right,top,bottom,centerhad no effect.
v0.13.0
(2024-02-20)
API Changes
Requires python >= 3.9
Using the
printorreprfunctions to draw and show the plot has been deprecated. Use ggplot.show().The name of the calculated aesthetic of
stat_functionchanged fromytofx.stat_ecdfhas gained thepadparameter. The default is set toTrue, which pads the domain with-infandinfso that the ECDF does not have discontinuities at the extremes. To get the behaviour, setpadtoFalse. (#725)Removed the environment parameter from
ggplot.When a ggplot object is the last in a jupyter cell, the output image will not be followed by string meta information about the figure/image.
This will happen even if the backend is set to an interactive one.
If you set the backend to an interactive one, use
showto draw the plot.The default horizontal alignment for the plot title is center if it there is no subtitle. When there is a subtitle, the default is to have both aligned to the left.
Some parameters that control the look and feel of
guide_colorbarandguide_legendhave been removed. For their place, thethemeparameter has been introduced and it gives better control of the look and feel.Themeables
legend_entry_spacing,legend_entry_spacing_xandlegend_entry_spacing_yhave been renamed tolegend_key_spacing,legend_key_spacing_xandlegend_key_spacing_yrespectivelyfacet_gridnow accepts two parameters,rowsandcols, to specify the variables along the two dimensions of the panels.The previous way of using a single parameter will still work if it is a string. For cases where the value was a list, e.g.
facet_grid(facets=["col1", "col2"])can be rewritten as any one of;
facet_grid("col1", "col2") facet_grid(["col1"], ["col2"]) facet_grid(rows="col1", cols="col2") facet_grid(rows=["col1"], cols=["col2"])The
facetsparameter infacet_wraphas also changed to a more straight forward specification for the column variables. It expects a single string or a list/tuple of strings. (#545)However, the R-style formula strings are still silently accepted.
New
Added symmetric logarithm transformation scales
scale_x_symlogandscale_y_symlogGained themeables
to set the plot margin on each side independently.
Gained themeables
axis_ticks_length_major_xaxis_ticks_length_major_yaxis_ticks_length_minor_xaxis_ticks_length_minor_y
to control the x & y axis ticks length.
Gained themeables
axis_ticks_pad_major_xaxis_ticks_pad_minor_y
to control the x & y tick padding.
Some parameters in
element_textcan now accept lists/tuples to set the values on individual text objects. (#724)Gained the option
figure_formatto set the format of the inline figures in an interactive session. e.g.from plotnine.options import set_option set_option("figure_format", "svg")will output all subsequent figures in svg format.
Improved support for customizing guides/legends.
You can now add a frame to the colobar
You can now apply themes to individual guides, e.g.
+ guides(color=guide_colorbar(theme=theme_xkcd()))or
+ guides(color=guide_legend(theme=theme_minimal())You can now place legends at more than one position around the panels. e.g.
+ guides( color=guide_colorbar(position="left"), fill=guide_legend(position="bottom"), size=guide_legend(position="bottom") )Puts the
fillandsizeguides at the bottom, and thecolorguide on the left.You can easily justify the legend along the four edges of the space around the panel area.
You can now place the legend inside the panels with easily control its location.
The
spaceparameter offacet_gridnow responds to the valuesfree,free_xandfree_yto have panels whose relative width and/or height depends on the data range. (#545)
Bug Fixes
Fixed handling of minor breaks in
scale_continuousto accept numpy arrays and when the scale has a transform, that the minor breaks are supplied in user space and not transform space. Just like the major breaks. (#685)Fixed theming of axis_ticks with the size parameter. (#703)
Fixed space handling around
axis_label,axis_textandaxis_tickswhen the ticks are turned off.Fixed bug in
geom_pathwhere the lineend parameter was ignored. (#727)Fixed bug where
theme(legend_background=element_blank())messed up the position of the legend, instead of only removing the background.Fixed using
facet_gridwith a column namedkey. (#734)Fixed using legend when using an identity scale and reordering the breaks. (#735)
Fixed drawing the upper outline of
geom_ribbon. (#728)Fixed issue where the gridlines overlap the panel border. (#638)
Enhancements
v0.12.4
(2023-11-06)
Bug Fixes
Fixed
position_dodgeto work with to work forgeom_segment.Fixed the
xlimits when plottinggeom_sina.Fixed
stat_boxplotandstat_ydensitywhen there is noxaesthetic.
Enhancements
- Return group counts for
stat_summary.
v0.12.3
(2023-09-01)
Enhancements
- Resolved Future Warnings from pandas-2.1.0
v0.12.2
(2023-07-21)
- This is a maintenance release that prevents newer versions of mizani from breaking plotnine. This version depends on
mizani<0.10.0.
v0.12.1
(2023-05-09)
New Features
A layout manager. Now you do not have to adjust spacing parameters to prevent objects around the panels from overlapping. Specifically, you can:
- Set the legend position to “top”, “left” or “bottom”
- Use a large or multiline plot title
- Use a large or multiline plot caption
- Use
facet_wrapwithscales="free"scales="free_x"orscales="free_y"
You can now also align the
plot_title,axis_title_x,axis_title_yandplot_captionwith respect to the panels. Set these to “left”, “right” & “center” for the horizontal flowing text. And “top”, “right” & “center” for the vertical flowing text.Also, the size of the figure is exactly determined by the theme setting. For example, this:
theme(figure_size=(8, 6), dpi=100)will create an
800px x 600pximage.You can create a
subtitleusinglabsand style it using theplot_subtitleparameter totheme.```py theme(plot_subtitle=element_text(size=8))
Enhancements
ggplotobject gained a new methodsave_helper. It gives you access to the matplotlib figure that will be saved to file.When plotting with an ipython interactive backend (e.g. in a jupyter notebook). The default image output is retina. You do not need to run this command.
%config InlineBackend.figure_format = "retina"Plotnine still respects any values set the user.
In an interactive setting, after drawing an image. The size of the figure (in pixels) is printed e.g.
<Figure Size: (640 x 480)>. Previously, something like<ggplot: (336175301)>was printed.
API Changes
__add__and__iadd__now accept the same types of objects. In this change__iadd__has gained the ability to accept a list of objects.drawno longer accepts the argumentreturn_ggplotand the return value is always a matplolib figure.Themeables
strip_margin,strip_margin_xandstrip_margin_y) have been renamed tostrip_align,strip_align_xstrip_align_yrespectively.subplots_adjusthas been deprecated. You no longer need to usetheme(subplots_adjust={"right": 0.85})and the like to make space for the legend or text around the panels. In the future, this will through an error.Changed default font-family (san-serif) from DejaVu Sans to Helvetica.
Bug Fixes
Fixed bug where a discrete position scale failed when mapping an empty variable. (#647)
Fixed bug where
facet_gridwith a datetime column run into an exception. (#629)Fixed bug where
geom_violinwith facetting and"scales = free"did not work. (#655)Fixed bug in
position_dodge2to work withpreserve="single"forgeom_rectand any other geoms that accept a min-max range along the x-axis.Fixed legend for
geom_pointto accurately display transparent fill colors that have been manually set. (#665)Fix issue where infinite limits for the
xoryscales lead to an exception. (#664)Fixed
geom_textandgeom_labelwhen used with string formatting so that missing values are removed. (#651)
v0.10.1
(2022-09-10)
This is a re-release of v0.10.0.
In the previous release the project description fileformat changed and not all references to it were corrected. PYPI read file that did not exist, got no description. This release is fixes error.
v0.10.0
(2022-09-10)
Bug Fixes
Fixed bug in
stat_bin_2dwhere bins whose edges are zero or negative would yield the wrong plot. (#604)Fixed bug
stat_density_2dwhich had been broken by Matplotlib 1.6.0. (#619)Fixed
geom_textwhen usingadjust_textfor the arrows to have the same color as the text.
New Features
geom_ribbonacquired new parameterwherewhich can be used shade within given limits .Added support for objects with a
to_pandasmethod to convert them to a pandas dataframe. You can now pass in polars dataframes.geom_ribbonacquired new parameteroutline_typewhich controls how to stroke the boundaries of the shaded area. This parameter is also available togeom_areaandgeom_density. (#605)
API Changes
The automatic groups generated by the system and depending on the aesthetic mappings now only depend those aesthetics that have scales. This is more strict than has been, should affect very few cases of code that has been written and it should be less surprising to the users.
geom_areaandgeom_densitynow default to showing only the upper outline/boundary of the area. Useoutline_type="full"for the old behaviour.
v0.9.0
(2022-07-01)
API Changes
- For the calls to
ggplot, the order of the positional arguments is(data, mapping)and for callsgeomsandstatsthe order is(mapping, data). In practice, you can still provide one/two positional arguments in any order. However, the are a few cases where old code will breaks due to duplicate parameters.
New Features
Added
geom_pointdensity, a 2D density plot that does not hide the distribution of the individual data points.position_dodge2gained the ability to reverse the order of the plotted groups. (#515)Added
theme_tufte, a theme that reduces the distractions around plot data.labscan now be used to create acaption. This caption can be styled using theplot_captionparameter totheme.theme(plot_caption=element_text(size=13))You can now align the
plot_titlehorizontally to the left or right.theme(plot_title=element_text(ha="left"))Before, the title was always centered.
Bug Fixes
Fixed bug in
facet_gridandfacet_wrapwhere thedropparameter was ignored. (#510)Fixed issue with
annotation_logtickswhere the wrong range was used for the x|y axis. (#525)Fixed bug in
geom_smoothwhere using a coordinate transformation without computing the standard error led to a crash. (#526)Fixed bug where you could not specific the cap/end of a dashed line when styling a plot with
element_line.Fixed legend for
geom_mapso that the entries have the same stroke and points on the map. (#534)Fixed
geom_histogramfor some cases when it fails to automatically determine the number of bins. (#543)Fixed
facet_gridandfacet_wrapwhen mapping to lists/arrays/series so that the rows mapped this way are not mixed up. (#548)Fixed
stat_bin_2dnot to error for matplotlib >= 3.5.0 so that it does not throw a Numpy error. (#567)Fixed
geom_mapto be able to draw Polygons with holes in them.Fixed
geom_mapto be able to draw MultiPolygons.Fixed
scale_x_discreteandscale_x_discreteto work properly withNonevalues. (#523)Fixed
geom_pointto respect not to use thefillmapping on unfilled shapes. (#100)Fixed
position_stackto work with scales that have non-linear transformations. e.g.scale_y_log10. (#580)Fixed scales to work with limits passed as a function.
Fixed
axis_ticksso you can change the colour of the axis ticks. This was probably a regression due to changes in Matplotlib.Fixed
panel_ontopso that if is set toFalse, then the data visualised below the grid-lines. (#585)Fixed
geom_ribbon,geom_areaandgeom_densityto work withcoord_flip. (#596)
Enhancements
stat_summarynow has a default summary function. (#528)stat_densitynow uses a fast computation path for gaussian densities with no weights. This was probably a regression.geom_mapcan now draw MultiPoints, MultiLineStrings and MultiPolygons.geom_textwithadjust_textcan now be used in more than one layer with good enough results.
v0.8.0
(2021-03-24)
API Changes
- How you map to calculated aesthetics has changed. Use the
after_statfunction. The old methods'stat(name)'and'..name..'have been deprecated.
New Features
You can now map to aesthetics at three different stages. See
aes,after_stat,after_scaleandstage.geom_violingained the a new parameterstylewith which you can draw half violin (density curve on one side and flat on the other).Added
geom_raster.geomsgained new parameterrasterfor thelayer. You can use it to rasterize any layer when the resulting plot is of vector format e.g.pdf.Using the
spaceparameter,facet_gridgained the ability to have rows and columns of panels of different sizes.
Bug Fixes
Fixed issue where some plots with a colorbar would fail for specific themes. (#424)
Fixed
geom_mapto plotMultiLineStringgeom types.Fixed
geom_textto allow any order ofmappinganddatapositional arguments.Fixed bug were the plotted image may have ignored theming that relied on some Matplotlib rcParams. (#451)
Fixed the
weightaesthetic ingeom_boxplot, previously ignored it is now recognised. (#438)Fixed
annotation_logticksandannotation_stripesto work without global data and aesthetics. (#469)Fix
scale_shape_discretewhen printing many unfilled shapes not to assign the same shapes to more than one group. (#473)Fixed bug in
stat_ellipsewhere the center of the ellipse assuming a multivariate t-distribution was incorrectly calculated. (#493)
Enhancements
Manual scales now match the values of the breaks if the breaks are given. (#445)
Using
printto show a ggplot object will not show the hash (<ggplot: ...>) anymore. There is now a difference betweenrepr(p)andstr(p). (#453)Added option to for the
base_familyof a theme, now you can set it once with and have it be applied to all themes. (#436)from plotnine.options import set_option set_option('base_family', 'Comic Sans MS')You can now add
Noneto a ggplot, doing so returns a copy of the the ggplot object. (#474)Better handling of multiline facet labels. (#484)
v0.7.1
(2020-08-05)
Bug Fixes
Fixed issue where a plot has no data and the geoms have no data, but the mappings are valid. (#404)
Fixed
preserve="single"inposition_dodgeandposition_dodge2to work for geoms that only havexaesthetic and notxminandxmaxe.ggeom_text.Fix regression in
v0.7.0where plots with a colorbar would fail if usingtheme_matplotlib.
v0.7.0
(2020-06-05)
API Changes
Changed the default method of calculating bandwidth for all stats that use kernel density estimation. The affected stats are
stat_density,stat_ydensity, andstat_sina. These stats can now work with groups that have a single unique value.Changed
scale_colour_continuousto refer to the same scale asscale_color_continuous.Changed
scale_color_cmapso the parametercmap_namerefers to the name of the color palette andnamerefers to the name of the scale. (#371)
New Features
aesgot an internal functionreorderwhich makes it easy to change the ordering of a discrete variable according to some other variable/column.stat_smoothcan now use formulae for linear models.
Bug Fixes
Fixed issue where a wrong warning could be issued about changing the transform of a specialised scale. It mostly affected the timedelta scale.
Fixed
geom_violinand other geoms when used withposition="dodge"not to crash when if a layer has an empty group of data.Fixed bug in
geom_pathfor some cases when groups had less than 2 points. (#319)Fixed all stats that compute kernel density estimates to work when all the data points are the same. (#317)
Fixed issue where setting the group to a string value i.e.
group="string"outsideaes()failed due to an error.Fixed issue where discrete position scales could not deal with fewer limits than those present in the data. (#342)
Fixed issue with using custom tuple linetypes~ with
scale_linetype_manual. (#352)Fixed
position_jitterdodgeto work whencoloris used as an aesthetic. (#372)Fixed skewed head in
arrowwhen drawn on facetted plot. (#388)Fixed issue with
stat_densitywhere weights could not be used with a gaussian model. (#392)Fixed bug where
guide_colorbarwidth and height could not be controlled bylegend_key_widthandlegend_key_height. (#360)
Enhancements
You can now set the bandwidth parameter
bwofstat_ydensity.Parameters
haandvaofgeom_texthave been converted to aesthetics. You can now map to them. (#325)All themes (except
theme_matplotlib) now do not show minor ticks. (#348)
v0.6.0
(2019-08-21)
API Changes
The
drawparameter ofgeom_maphas been removed. Shapefiles should contain only one type of geometry and that is the geometry that is drawn.Ordinal (Ordered categorical) columns are now mapped to ordinal scales. This creates different plots.
The default mapping for the computed aesthetic size of
stat_sumhas changed to'stat(n)'. This also changes the default plot forgeom_count.
New Features
geom_textgained theadjust_textparameter, and can now repel text.- Added
annotation_logticks. - Added
geom_sina - Added scales for ordinal (ordered categorical) columns.
geom_stepgained the optionmidfor the direction parameter. The steps are taken mid-way between adjacent x values.- Added
annotation_stripes.
Bug Fixes
Fixed bug where facetting would fail if done on a plot with annotation(s) and one of the facetting columns was also a variable in the environment.
Fixed bug where
coord_flipwould not flip geoms created bygeom_rug. (#216)Fixed bug where plots with
theme_xkcdcannot be saved twice. (#199)Fixed bug that made it impossible to map to columns with the same name as a calculated columns of the stat. (#234)
Fixed bug in
geom_smooththat made it difficult to use it with stats other thanstat_smooth. (#242)Fixed bug in
position_dodgewhere by bar plot could get thinner when facetting and usingpreserve = 'single'. (#224)Fixed bug in
coord_transwhere if the transformation reversed the original limits, the order in which the data was laid out remained unchanged. (#253)Fixed bug in
stat_countwherefloatweights were rounded and lead to a wrong plot. (#260)Fixed bug where one could not use the British spelling
colourto rename a color scale. (#264)Fixed bug in
lims,xlim, andylimwheredatetimeandtimedeltalimits resulted in an error.Fixed bug where
geom_rectcould not be used withcoord_trans. (#256)Fixed bug where using free scales with facetting and flipping the coordinate axes could give unexpected results. (#286)
Fixed unwanted tick along the axis for versions of Matplotlib >= 3.1.0.
Fixed
geom_textnot to error when usinghjustandvjust. (#287)Fixed bug where
geom_ablinegeom_hlineandgeom_vlinecould give wrong results when used withcoord_trans.Fixed bug where layers with only infinite values would lead to an exception if they were the first layer encountered when choosing a scale.
Enhancements
Legends are now plotted in a predictable order which dedends on how the plot is constructed.
The spokes drawn by
geom_spokecan now have a fixed angle.Aesthetics that share a scale (e.g. color and fill can have the same scale) get different guides if mapped to different columns.
When the transform of a specialised (one that is not and identity scale) continuous scale is altered, the user is warned about a possible error in what they expect. (#254, #255)
The
method_argsparameter instat_smoothcan now differentiate between arguments for initialising and those for fitting the smoothing model.position_nudgecan now deal with more geoms e.g.geom_boxplot.The
limitsparameter ofscale_x_discreteandscale_y_discretecan now be a function.The
widthof the boxplot can now be set irrespective of the stat.The mid-point color of
scale_color_distillernow matches that of the trained data.The way in which layers are created has been refactored to give packages that that extend plotnine more flexibility in manipulating the layers.
You can now specify one sided limits for coordinates. e.g.
coord_cartesian(limits=(None, 10)).All the themeables have been lifted into the definition of
themeso they can be suggested autocomplete.
v0.5.1
(2018-10-17)
Bug Fixes
- Changed the dependency for mizani to
v0.5.2. This fixes an issue where facetting may create plots with missing items. (#210)
v0.5.0
(2018-10-16)
API Changes
Bug Fixes
Fixed issue where with the
subplots_adjustthemeable could not be used to set thewspaceandhspaceMatplotlib subplot parameters. (#185)Fixed in
stat_binwhere setting custom limits for the scale leads to an error. (#189)Fixed issue interactive plots where the x & y coordinates of the mouse do not show. (#187)
Fixed bug in
geom_ablinewhere passing the mapping as a keyword parameter lead to a wrong plot. (#196)Fixed issue where
minor_breaksfor transformed scaled would have to be given in the transformed coordinates. Know they are given the data coordinates just like the majorbreaks.
Enhancements
For all geoms, with
coord_cartesianfloat('inf')ornp.infare interpreted as the boundary of the plot panel.Discrete scales now show missing data (
Noneandnan). This behaviour is controlled by the newna_translateoption.The
minor_breaksparameter for continuous scales can now be given as an integer. An integer is taken to control the number of minor breaks between any set of major breaks.
v0.4.0
2018-01-08
API Changes
Calculated aesthetics are accessed using the
plotnine.aes.statfunction. The old method (double dots..name..) still works.stat_qqcalculates slightly different points for the theoretical quantiles.The
scales(when set to free, free_x or free_y) parameter offacet_gridandfacet_wrapassigns the same scale across the rows and columns.
New Features
Added
geom_qq_lineandstat_qq_line, for lines through Q-Q plots.Added
geom_density_2dandstat_density_2d.Added
stat_ellipse.Added
geom_map.Plotnine learned to respect plydata groups.
Added
stat_hull.Added
save_as_pdf_pages.
Bug Fixes
Fixed issue where colorbars may chop off the colors at the limits of a scale.
Fixed issue with creating fixed mappings to datetime and timedelta type values. (#88)
Fixed
scale_x_datetimeandscale_y_datetimeto handle the intercepts along the axes. (#97)Fixed
stat_binandstat_bin_2dto properly handle thebreaksparameter when used with a transforming scale.Fixed issue with x and y scales where the
nameof the scale was ignored when determining the axis titles. Now, thenameparameter is specified, it is used as the title. (#105)Fixed bug in discrete scales where a column could not be mapped to integer values. (#108)
Make it possible to hide the legend with
theme(legend_position="none"). (#119)Fixed issue in
stat_summary_binwhere some input values gave an error. (#123)Fixed
geom_ribbonto sort data before plotting. (#127)Fixed
IndexErrorinfacet_gridwhen row/column variable has 1 unique value. (#129)Fixed
facet_gridwhenscale="free",scale="free_x"orscale="free_y", the panels share axes along the row or column.Fixed
geom_boxplotso that user can create a boxplot by specifying all required aesthetics. (#136)Fixed
geom_violinto work when some groups are empty. (#131)Fixed continuous scales to accept
minor=None. (#120)Fixed bug for discrete position scales, where
drop=Falsedid not drop unused categories. (#139)Fixed bug in
stat_ydensitythat caused an exception when a panel had no data. (#147)Fixed bug in
coord_transwhere coordinate transformation and facetting could fail with aKeyError. (#151)Fixed bug that lead to a
TypeErrorwhen aesthetic mappings to could be recognised as being groupable. It was easy to stumble on this bug when usinggeom_density. (#165)Fixed bug in
facet_wrapwhere some combination of parameters lead to unexpected panel arrangements. (#163)Fixed bug where the legend text of colorbars could not be themed. (#171)
v0.3.0
(2017-11-08)
API Changes
geom_smoothgained an extra parameterlegend_fill_ratiothat control the area of the legend that is filled to indicate confidence intervals. (#32)savegained an extra parameterverbose. It no longer guesses when to print information and when not to.drawgained an extra parameterreturn_ggplot.If the
minor_breaksparameter of scales is a callable, it now expects one argument, thelimits. Previously it acceptedbreaksandlimits.
New Features
- Added
PlotnineAnimationfor animations. - Added
watermarkfor watermarks. - Added datetime scales for
alpha,colour,fillandsizeaesthetics
Enhancements
Changed parameter settings for
stat_smooth.- Default
span=0.75instead of2/3 - When using loess smoothing, the control parameter
surfaceis only set to the value'direct'if predictions will be made outside the data range.
- Default
Better control of scale limits. You can now specify individual limits of a scale.
scale_y_continuous(limits=(0, None)) xlim(None, 100)You can also use
expand_limitsLow and high
scalelimits can now be expanded separately with different factors multiplicative and additive factors.The layer parameter
show_legendcan now accept adictfor finer grained control of which aesthetics to exclude in the legend.Infinite values are removed before statistical computations
stats. (#40).statsalso gained new parameterna_rm, that controls whether missing values are removed before statistical computations.qplotcan now use the name and a Pandas series to label the scales of the aesthetics.You can now put stuff to add to a ggplot object into a list and add that that instead. No need to wrap the list around the internal class
Layers.lst = [geom_point(), geom_line()] g = ggplot(df, aes('x', 'y')) print(g + lst)Using a list allows you to bundle up objects. It can be convenient when creating some complicated plots. See the Periodic Table Example.
You can now use a
dict(with manual scales) to map data values to aesthetics. (#169)You can now specify infinite coordinates with
geom_rect. (#166)
Bug Fixes
Fixed bug where facetting led to a reordering of the data. This would manifest as a bug for
geomswhere order was important. (#26)Fix bug where facetting by a column whose name (eg.
class) is a python keyword resulted in an exception. (#28)Fix bug where y-axis scaling was calculated from the
xlimargument.Fix bug where initialising geoms from stats, and positions from geoms, when passed as classes (e.g.
stat_smooth(geom=geom_point), would fail.Fixed bug in
savewhere specifying thewidthandheightwould mess up thestrip_textandspacingfor the facetted plots. (#44).Fixed bug in
geom_abline,geom_hlineandgeom_vlinewhere facetting on a column that is not mapped to an aesthetic fails. (#48)Fixed bug in
geom_text, thefontstyleparameter was being ignored.Fixed bug where boolean data was mapped to the same value on the coordinate axis. (#57)
Fixed bug in
facet_gridwhere thescalessometimes has no effect. (#58)Fixed bug in
stat_boxplotwhere setting thewidthparameter caused an exception.
v0.2.1
(2017-06-22)
Fixed bug where manually setting the aesthetic
fill=Noneorfill="None"could lead to a black fill instead of an empty fill.Fixed bug where computed aesthetics could not be used in larger statements. (#7)
Fixed bug in
stat_summarywhere the you got an exception for some types of thexaesthetic values.Fixed bug where
ggplot(data=df)resulted in an exception.Fixed missing axis ticks and labels for
facet_wrapwhen the scales are allowed to vary (e.gscales="free") between the panels.Fixed bug in
stat_densitywhere changing the x limits lead to an exception. (#22)
v0.2.0
(2017-05-18)
Fixed bug in
scale_x_discreteandscale_y_discretewhere if they were instantiated with parameterlimitsthat is either a numpy array or a pandas series, plotting would fail with aValueError.Fixed exceptions when using
pandas.pivot_tablefor Pandas v0.20.0. The API was fixed.Fixed issues where lines/paths with segments that all belonged in the same group had joins that in some cases were “butted”.
API Changes
geom_textnow useshaandvaas parameter names for the horizontal and vertical alignment. This is what matplotlib users expect. The previous nameshjustandvjustare silently accepted.plotnine.layer.Layerscan now be used to bundle upgeomsandstats. This makes it easy to reusegeomsandstatsor organise them in sensible bundles when making complex plots.
v0.1.0
(2017-04-25)
First public release