github has2k1/plotnine v0.12.1

latest releases: v0.12.3, v0.12.3a1, v0.12.2...
18 months ago

(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:

    1. Set the legend position to "top", "left" or "bottom"
    2. Use a large or multiline plot title
    3. Use a large or multiline plot caption
    4. Use facet_wrap with scales="free" scales="free_x" or `scales="free_y"

    You can now also align the plot_title, axis_title_x, axis_title_y and plot_caption with 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 600px image.

  • You can create a subtitle using labs and style it using the plot_subtitle parameter to theme.

theme(plot_subtitle=element_text(size=8))

Enhancements

  • ggplot object gained a new method save_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.
  • draw() no longer accepts the argument return_ggplot and the return value is always a matplolib figure.
  • Themeables strip_margin, strip_margin_x and strip_margin_y have been renamed to strip_align(), strip_align_x() strip_align_y() repectively.
  • subplots_adjust has been deprecated. You no longer need to use theme(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_grid with a datetime column run into an exception. (#629)
  • Fixed bug where geom_violin with facetting and "scales = free" did not work. (#655)
  • Fixed bug in position_dodge2 to work with preserve="single" for geom_rect and any other geoms that accept a min-max range along the x-axis.
  • Fixed legend for geom_point to accurately display transparent fill colors that have been manually set. (#665)
  • Fix issue where infinite limits for the x or y scales lead to an exception. (#664)
  • Fixed geom_text and geom_label when used with string formatting so that missing values are removed. (#651)

Don't miss a new plotnine release

NewReleases is sending notifications on new releases.