Skip to content

ggrust 0.9.0

Latest

Choose a tag to compare

@Zaf4 Zaf4 released this 15 Nov 14:14
· 11 commits to main since this release

Added

  • geom_band, as lets-plot: a band across the whole panel between xmin and xmax (vertical) or ymin and ymax (horizontal), mapped or constant (geom_band(xmin=1, xmax=2)), with edge lines and alpha on the fill only.
  • geom_bracket_dodge, as lets-plot: brackets between the dodged groups istart and iend of category x (ngroup, dodge_width), same bars, tips and labels as geom_bracket.
  • residual_plot (bistro), as lets_plot: from ggrust.bistro import residual_plot plots the residuals of a polynomial (method="lm", deg=) or local ("loess", needs statsmodels and scipy) fit of y on x, with a dashed line at zero and marginal densities; as_dict() matches lets_plot's.
  • image_matrix (bistro), as lets_plot: a grid of geom_imshow images from a 2D object array (cmap, norm, vmin, vmax, scale, spacer); the cells are inset_element figures, so it returns a PlotSpec. Empty (None) cells stay blank.
  • nudge_unit="size"/"px" on geom_text, geom_label, geom_text_repel, geom_label_repel and geom_bracket: the nudge is added in point diameters (2.2 px) or pixels after the coord, as lets-plot. alpha_stroke=True on geom_label and geom_label_repel fades the text and border by alpha too.
  • scale_identity(aesthetic, ...), the generic identity scale of lets-plot: a name or a list (scale_identity(['color', 'fill'])). The module of the per-aesthetic identity scales is now ggrust.plot.scale_identity_ (lets-plot's name), so ggrust.plot.scale_identity is the function.
  • joint_plot and qq_plot (bistro), as lets_plot: from ggrust.bistro.joint import joint_plot draws points, 2D bins or a 2D density with a dashed regression line and marginal histograms, densities or boxplots; from ggrust.bistro.qq import qq_plot draws a sample against a theoretical distribution (or two samples against each other) with the fitted line and marginal densities of the quantiles. joint_plot's as_dict() matches lets_plot's.
  • Animation, after gganimate: p + transition_manual("year", cumulative=False) draws one frame per value; animate(plot, nframes=, fps=, duration=, detail=, start_pause=, end_pause=, rewind=, width=, height=, dpi=) plans the frames as gganimate and returns an Animation (.frame(i), .save(), .to_gif(), .to_apng(), .to_html()). {current_frame}, {frame}, {nframes} and {progress} in the title, subtitle and caption are filled per frame. Notebooks show an HTML player (play, pause, slider); anim_save("x.gif") and ggsave(plot, "x.gif" | "x.png" | "x.html") write a GIF, animated PNG or player page. Scales are trained once, so axes stay fixed; stats and positions run per frame.
  • Animation states, after gganimate: p + transition_states("year", transition_length=1, state_length=1, wrap=True) holds each state and moves the marks smoothly into the next (rows matched by group; numbers and sizes eased, colours through CIE Lab, categories switch halfway), and ease_aes("cubic-in-out", y="bounce-out") picks tweenr's easing per aesthetic. Labels gain {closest_state}, {previous_state}, {next_state} and {transitioning}.
  • Animation over time, after gganimate: p + transition_time("year", range=None) spaces the frames evenly in time and moves the marks between the observed times (dates and date-times too), and p + transition_reveal("date", range=None, keep_last=True) grows lines, areas and polygons along a column with an interpolated end point while points travel along their group. Labels gain {frame_time} and {frame_along}.
  • Animation enter/exit effects and shadows, after gganimate: enter_fade(alpha=0), exit_fade(alpha=0), enter_grow(size=0) and exit_shrink(size=0) let marks without a partner in the next state fade, grow or shrink in and out over the transition (bars from the axis, lines and polygons from their centre; effects added with + apply in order); shadow_wake(wake_length, size=True, alpha=True, colour=None, fill=None, falloff="cubic-in", wrap=True, exclude_layer=None, exclude_phase=("enter", "exit")) trails moving marks with their last frames, and shadow_mark(past=True, future=False, exclude_layer=None, **styles) keeps earlier (or later) states in the background. Work with transition_states and transition_time.

Fixed

  • Animated GIFs are 2.5x to 22x smaller and about 3x faster to write: frames that come out pixel-identical are merged into one longer frame, and each later frame holds only the rectangle that changed, with unchanged pixels transparent (as gifski does). Frames of at most 255 colours keep their exact colours.
  • Animated lines and polygons whose point count changes between states now morph smoothly: points are inserted along the shape as gganimate (transformr) does, every shape gets at least 50 points, polygons are drawn clockwise and rotated for the least travel. The warning about points matched in order is gone.
  • Animation labels pad years to 4 digits (0001-01-01, as R), and a date-time column uses one label format for the whole animation: the time shows in every frame when any value has one, so midnight no longer prints the date alone next to frames with times (gganimate formats each frame alone; decided by the user).
  • Animations of a date or date-time column label states as dates ({current_frame}, {closest_state}, ...), not epoch numbers, and transition_time/transition_reveal reject a range of the wrong kind for the column (numbers for a date column, dates for a numeric one) with a SpecError.
  • ggsave(anim.frame(i), "x.png") writes that one frame as a still PNG (it wrote the whole animation as APNG); SVG, PDF and the notebook display of a frame are still too, and .gif of a frame is an ExportError.
  • A continuous legend over a single value shows one key at that value, as ggplot2, not about five near-identical ones (lets-plot #1267).
  • Legend keys with the same label but different values no longer merge (lets-plot #1129): scale_color_manual(labels=['A', 'A', 'C']) shows three keys, as ggplot2.