
Text annotations can optionally be added to a shape using the add_text keyword argument, and positioned using the x and y arguments: Library ( dash ) library ( dashCoreComponents ) library ( dashHtmlComponents ) library ( plotly ) data ( "iris" ) vline % layout ( plot_bgcolor = "#e5ecf6", shapes = list ( vline ( value ), list ( type = "rect", fillcolor = "red", line = list ( color = "red" ), opacity = 0.2, y 0 = 0.9, y 1 = 2.6, x 0 = 0.5, x 1 = 7.5 ))) return ( fig ) })Īfter executing this code, give app$run_server() in the console to start the dash. The following shows some possibilities, try panning and zooming the resulting figure to see how the shapes stick to some axes: These shapes are fixed to the endpoints of one axis, regardless of the range of the plot, and fixed to data coordinates on the other axis. Shapes added with these methods are added as layout shapes.

Horizontal and vertical lines and rectangles that span an entire plot can be added via the shapes parameter of layout. Horizontal and Vertical Lines and Rectangles
#Plotly line graph r how to#
How to add annotated horizontal and vertical lines in R. Horizontal and Vertical Lines and Rectangles in R
#Plotly line graph r upgrade#
We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials.
#Plotly line graph r free#
Plotly is a free and open-source graphing library for R. How to add annotated horizontal and vertical lines in R

