You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Not able to show Regression Line Equation using ggplotly #1687
I need to display Regression Line Equation with the lineplot. I am using "stat_poly_eq" function present in "ggpmisc" package. Able to achieve it with ggplot (Find attached screenshot). But when when I am trying to show plot using ggplotly regression equition is getting disppeared (Find attached screenshot)
Layer function stat_poly_equation() is flexible enough to work with 'ggplotly' if some defaults are overriden. One needs to be careful about the positioning of the text labels as some manual tweaking is required.
The geom used by default is geom_text_npc() from 'ggpp', which is unknown to 'ggplotly', so we need to use geom_text() instead. 'ggplotly' does not seem to understand character strings that are meant to be parsed into expressions or even respect justification in geom_text(). However, there are workarounds available for all these limitations. The pure-text labels lack italics and super- and subscripts, as stat_poly_eq() currently uses the ASCII character set for equations formatted with output.type = "text".
Activity
cpsievert commentedon Feb 4, 2020
Added to #566
aphalo commentedon Jun 24, 2023
Layer function
stat_poly_equation()is flexible enough to work with 'ggplotly' if some defaults are overriden. One needs to be careful about the positioning of the text labels as some manual tweaking is required.The geom used by default is
geom_text_npc()from 'ggpp', which is unknown to 'ggplotly', so we need to usegeom_text()instead. 'ggplotly' does not seem to understand character strings that are meant to be parsed into expressions or even respect justification ingeom_text(). However, there are workarounds available for all these limitations. The pure-text labels lack italics and super- and subscripts, asstat_poly_eq()currently uses the ASCII character set for equations formatted withoutput.type = "text".This PNG is downloaded from the plotly plot.
aphalo commentedon Jun 24, 2023
@cpsievert I think the best way to enhance 'ggplotly' would be to implement support for
geom_richtext()from package 'ggtext'.