Reputation: 99
I have example like this:
library(data.table)
library(plotly)
data1<-data.table(rbind(c(0,'Very long text'),c(4,'Very, very, very, very long
text')))
colnames(data1)<- c('A','B')
plot_ly(data=data1,y=~A, x=~B,type='bar') %>%
layout(xaxis=list(tickangle=45),
margin=list(b=200))
And problem is that the name of xaxis is close to xaxis and it can interfere with tick labels.
Is there possibility to move downward name of xaxis?
Upvotes: 2
Views: 4720
Reputation: 169
There is (now) an option called standoff
which can be set in the title layout which controls the distance between the axis and the title.
library(data.table)
library(plotly)
data1<-data.table(rbind(c(0,'Very long text'),c(4,'Very, very, very, very long
text')))
colnames(data1)<- c('A','B')
plot_ly(data=data1,y=~A, x=~B,type='bar') %>%
layout(xaxis=list(tickangle=45, title = list( text ="my title", standoff = 50)))
Upvotes: 2
Reputation: 21
I have started using annotations to make my own axis labels where I want them and how I want them. Check out the annotations "example" under layout at https://plot.ly/javascript/reference/. There is a small learning curve but then you are in charge.
Sample
var layoutS =
{
title:'Plot',
xaxis1:{
zeroline:false,
zerolinewidth:1,
showline:true,
showticklabels:true,
ticks:'outside',
},
yaxis1:{
zeroline:true,
zerolinewidth:1,
showline:true,
showticklabels:true,
ticks:'outside',
},
width:graphWidth,
height:graphHeight,
annotations:[
{
xref:'paper',
yref:'paper',
x:0,
xanchor:'center',
y:1.1,
yanchor:'bottom ',
text:'x[n]',
showarrow:false
},
{
xref:'paper',
yref:'paper',
x:1.1,
xanchor:'left',
y:0,
yanchor:'top',
text:'n',
showarrow:false
}
]
}
Upvotes: 1
Reputation: 1460
Plotly documentation does not list an option for moving xaxis
title. Easiest (but nasty) workaround is using \r\n
in xaxis=list(tickangle=45, title = "\r\n B")
.
Upvotes: 0