Skip to content

Conversation

@Chr96er
Copy link

@Chr96er Chr96er commented Jan 28, 2026

Summary

Fixes #2364 - JSON doesn't support Inf values, causing geoms to not render when users specify Inf/-Inf coordinates (a common pattern for "extend to edge" annotations).

Changes

  • Added centralized replace_inf_in_data() function in R/utils.R that replaces Inf values with panel limits
  • Applied after to_basic() returns in R/layers2traces.R, handling all geoms generically (geom_line, geom_rect, geom_polygon, geom_ribbon, geom_segment, etc.)

Test plan

  • Added test for geom_line with Inf y values (original issue)
  • Added test for geom_rect with Inf x/y values
  • Added test for geom_polygon with Inf x/y values
  • Added test for faceted plots with Inf values
  • Tests verify replaced values match expected panel limits
  • All 211 relevant tests pass

JSON doesn't support Inf values - they become null, causing geoms like
geom_rect, geom_polygon, geom_line, geom_ribbon, and geom_segment to
not render when users specify Inf/-Inf coordinates (a common pattern
for "extend to edge" annotations).

This fix adds centralized Inf replacement in the ggplot2-to-plotly
conversion pipeline, replacing Inf values with the corresponding
panel limits after to_basic() returns. This handles all geoms
generically without requiring individual fixes.

Includes tests for geom_line, geom_rect, geom_polygon, and faceted
plots to verify both that Inf values are replaced and that the
replacement values match the expected panel limits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plotly cannot handle Inf or -Inf when plotting

1 participant