How to change axis features in plotly?

Behmah

I have the following bar in plotly and I want to :

  1. get the x-axis title away from the axis label so they dont overlap
  2. make the Y-axis labels bigger
  3. bring the bar values to the top of bars

enter image description here

My code is :

library(plotly)
plot_ly(x = c('100-200','200-400', '400-600','600-800','800- 1000'),
y = c(12261,29637,17469,11233,17043),          
name = "dd",
type = "bar", 
 xaxis = list(title ="tr"),
yaxis = list(title = "cc") ,                                                
 text = c(12261,29637,17469,11233,17043),textposition = 'auto') %>%
layout(
xaxis = list(tickangle=15, title = " "),
 yaxis = list(title = " "))

Thanks for your comments :)

Marco Sandri

Question 1: get the x-axis title away from the axis label so they dont overlap
This problem can be solved setting proper margins with margin = list(b=100, l=100) in layout.

Question 2: make the Y-axis labels bigger.
Use xaxis = list(titlefont=list(size=30)) in layout

Question 3: bring the bar values to the top of bars.
Use add_text with textposition = 'top'

library(plotly)

x <- c('100-200','200-400', '400-600','600-800','800-1000')
y <- c(12261,29637,17469,11233,17043)
labs <- c(12261,29637,17469,11233,17043)

plot_ly(x = x, y = y,          
 name = "dd",
 type = "bar", 
 xaxis = list(title ="tr"),
 yaxis = list(title = "cc")) %>%
add_text(x=x, y=y, text=labs, hoverinfo='none', textposition = 'top', showlegend = FALSE, 
        textfont=list(size=20, color="black")) %>%
layout(margin = list(b=100, l=100),
 xaxis = list(tickangle=15, title = "Lenght of exon", titlefont=list(size=30)),
 yaxis = list(title = "Number of genes", titlefont=list(size=30)))

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Plotly: How to change the colorscheme of a plotly express scatterplot?

Plotly: How to change the time resolution along the x-axis?

Change axis title position in ggplot using plotly

How to set X axis range on plotly graphs?

How to get plotly to not ignore my axis settings?

Plotly: How to set the range of the y axis?

How to Change x-axis to logarithmic in PLOTLY histogram

Plotly: How to add axis layouts into a subplot?

Plotly: How to plot a multiple y axis?

Plotly: How to change the format of the values for the x axis?

How to change axis titles when using sliders in plotly

In Plotly, how to change axis titles dynamically when switching between different graphs using an Update button

Plotly: How to customize axis transformation?

Plotly: How to hide axis titles in a plotly express figure with facets?

How do you rotate the axis of a plot in Plotly?

Plotly: How to change default date on x-axis and remove year from axis?

Plotly: Change y-axis scale

Change axis of plotly polar plot

Change format of y axis in plotly

How to change x-axis layout using plotly in r

Plotly: How to change the range of the y-axis of a subplot?

How to change the x-axis and y-axis labels in plotly?

How to dynamically change the scale/ticks of y axis in plotly charts upon zooming in?

In an animated plotly scatter plot, how to change the axis scale per frame... but in R? (adapt a python solution?)

How to insert x axis labels in a Plotly timeline?

plotly express | change tick units on y axis

Plotly - change range of x-axis (date)

How can I change the distance between the axis title and the axis values in a 3D scatterplot in Plotly (Python)?

How to change point separator for the y-axis of a Plotly figure?