Skip to content

Commit 058a9bc

Browse files
authored
fix dropping of inf values from jitter plot (#4933)
* fix dropping of inf values from jitter plot * add change info as a bullet in news
1 parent d54fd69 commit 058a9bc

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# ggplot2 (development version)
22

3+
* Fix a bug in `position_jitter()` where infinity values were dropped (@javlon,
4+
#4790).
5+
36
* `geom_linerange()` now respects the `na.rm` argument (#4927, @thomasp85)
47

58
* Improve the support for `guide_axis()` on `coord_trans()` (@yutannihilation, #3959)

R/position-jitter.r

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ PositionJitter <- ggproto("PositionJitter", Position,
8787
fixed_jitter <- with_seed_null(params$seed, transform_position(dummy_data, trans_x, trans_y))
8888
x_jit <- fixed_jitter$x - x
8989
y_jit <- fixed_jitter$y - y
90+
# Avoid nan values, if x or y has Inf values
91+
x_jit[is.infinite(x)] <- 0
92+
y_jit[is.infinite(y)] <- 0
9093

9194
# Apply jitter
9295
transform_position(data, function(x) x + x_jit, function(x) x + y_jit)

0 commit comments

Comments
 (0)