Easy Error Bars with R and Plotly

[This article was first published on Modern Data » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Error bars are a great way to visually represent variability of a dataset, and are easy to graph with Plotly and R! Error bars can be used to visualize standard deviations, standard errors or confidence intervals (just don’t forget to specify which measure the error bar in the graph represents).

Below are two examples that demonstrate how to graph a variety of error bars. The complete R script and data used to create these 2 graphs are available here!

To create vertical error bars, like on the Snow line in the graph below, set
error_y = list(           type = "data",           array = c(YOUR_VALUES))

It is also possible to calculate and plot error bars with a percent value, like on the Rain line below. Set:
error_y = list(           type = "percent",           value = CHOOSE_%_VALUE)

To create horizontal error bars use error_x. Furthermore, it’s easy to graph asymmetrical error bars. Just set symmetric = FALSE and add an arrayminus array like this:

error_x = list(           type = "data",           symmetric = FALSE,           array = c(YOUR_HIGH_VALUES),           arrayminus = c(YOUR_LOW_VALUES))

Creating dashboards or visualizations at your company? Consider Plotly Enterprise for modern intracompany graph and data sharing.

To leave a comment for the author, please follow the link and comment on their blog: Modern Data » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)