line break and subscript in axis title using plotly in R


I just started to use plotly for some interactive scatter plots in R and having a hard time on axis labels. Normally I designed my plots with ggplot2 and then using the ggplotly function to convert them, but this is sometimes very slow for any reason. So I want to create my plots directly in plotly...

I am trying now to change the axis title and want to add line breaks and later I also want to add subscript labels. But I am already failing at the newline in the title. Is there any trick?

library(plotly) library(dplyr) plot_ly(mtcars, x = wt, y = mpg, text = rownames(mtcars), mode = "text") %>% layout(xaxis=list(title='text with\nlinebreak'))


In plotly, you can get linebreaks (and other text formatting) using html tags.

So piping

layout(xaxis=list(title='text with <br> linebreak'))

should work.

Hence, to get subscript labels use the <sub> tag. For example


will give you



  • Warning: Memcache::get() [memcache.get]: Node no longer exists
  • Python Requests library sometimes fails to open site that a browser can open
  • Codeigniter sending email to multiple email ids, file attachment is not going with emails
  • RestSharp PUT XML, RestSharp is sending it as GET?
  • Footer consisting of two right triangles
  • Bluetooth on Raspberry Pi Zero W, using buildroot
  • ProgressDialog.show inside AsyncTask stop my Program from execution
  • How to load PDFs from Documents Directory?
  • Web API Routing - Overloaded GET method causes 405 Method Not Allowed for other verbs
  • How to scroll the horizontal scrollbar in an iFrame from the parent frame?
  • JSON.stringify() - Escaping Issue
  • maximizing profit for given stock data via DP
  • Migrating MOSS 2007 from SQL 2000 to SQL 2005 [closed]
  • Customize jQuery submenu positioning
  • Project Euler -Prob. #20 (Lua)
  • Newtonsoft.json serializing and deserializing base/inheirited where classes are from shared projects
  • Is it possible to add a hyperlink to a UIAlertController?
  • Limit number of button clicks
  • Finding all XML nodes between each two processing instructions
  • Use 2D Text into 3D scenes in JavaFX results in blurry texts
  • How to organize this layout with overflows?
  • Slick: How can I combine a SQL LIKE statement with a SQL IN statement
  • Auto send email based on the time and email address in database
  • ASP.NET MVC 2 actions for the same route?
  • Possible to set default CloudKit container not based on application name?
  • openpyxl - adding new rows in excel file with merged cell existing
  • Typeahead.js does give me suggestions but doesn't select them
  • concise way of flattening multiindex columns
  • gnuplot - How to make zmin equal to zmax keeeping autoscale on z axis
  • Is there a better way for handling SpatialPolygons that cross the antimeridian (date line)?
  • How to clear a browser cache in Protractor
  • How to call jQuery function in HTML returned by AJAX
  • Change cell value based on cell color in google spreadsheet
  • How do I add a mouse over tooltip to an Image using .DrawImage()
  • How to integrate angular2-material (alpha 8.2) with angular2-Quickstart app
  • How to warp text around image in iOS?
  • Send array to next viewcontroller iOs xcode [duplicate]
  • Comma decimal separator is ignored by ASP.NET MVC model binder
  • Cross compile glibc for arm, got undefined reference to some unwind functions
  • Running R's aov() mixed effects model from Python using rpy2