Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Plotly and left alignment

I am working with Plotly. I have a double asterisk under this bar chart. Below you can see code and chart

library(plotly)
library(reshape2)
library(dplyr)

plot_ly(
  x = c("giraffes*", "whale**", "monkeys"),
  y = c(20, 14, 23),
  name = "SF Zoo",
  type = "bar"
) |> 
  layout(annotations = 
           list(x = 0, y =-0.131, 
                text = "Note: * The tallest animal,Unsurprisingly, the giraffe is the world's tallest living animal by standing height. Male giraffes can measure up to 6 meters or almost 20 feet, but with a height of up to 5.2 meters or 17 feet \n Note: ** Тhe longest animal" ,
                showarrow = F, 
                xref='paper', 
                yref='paper')
  )

enter image description here

In the above pic, you can see that the second note has center alignment. So I want to change this with left alignment. So can anybody help me how to solve this problem ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can set align in your annotations like this:

library(plotly)
library(reshape2)
library(dplyr)

plot_ly(
  x = c("giraffes*", "whale**", "monkeys"),
  y = c(20, 14, 23),
  name = "SF Zoo",
  type = "bar"
) |> 
  layout(annotations = 
           list(x = 0, y =-0.131, 
                text = "Note: * The tallest animal,Unsurprisingly, the giraffe is the world's tallest living animal by standing height. Male giraffes can measure up to 6 meters or almost 20 feet, but with a height of up to 5.2 meters or 17 feet \n Note: ** Тhe longest animal" ,
                showarrow = F, 
                xref='paper', 
                yref='paper',
                align = "left")
  )

Output:

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading