X-axis gets hidden in Plotly - R

不羁岁月 提交于 2019-12-11 13:55:18

问题


I am using plotly. Every graph that I make, has x-axis half hidden. It happens even if I use variables of x-axis as y-axis. For example, consider the following dataset:

structure(list(City = c("MUMBAI", "DELHI", "KOLKATTA", "HYDERABAD", 
"PUNE", "BANGALORE", "AHMEDABAD", "LUCKNOW", "AGRA", "BHUBANESHWAR", 
"GUWAHATI", "NAGPUR", "DELHIN.C.R", "MANGALORE", "INDORE"), OppLoss = c(48, 
44, 41, 38, 56, 43, 44, 43, 42, 32, 31, 43, 47, 25, 41)), .Names = c("City", 
"OppLoss"), row.names = c(32L, 13L, 26L, 17L, 35L, 5L, 2L, 27L, 
1L, 8L, 16L, 33L, 14L, 30L, 18L), class = "data.frame")

I have used the following code:

 plot_ly(n, x = OppLoss, y = City, name = OppLoss, mode = "markers", marker = list("pink"))

The same is the case with bar charts, line charts, etc. I have tried changing the setting by using the following code:

f <- list(
  family = "Courier New, monospace",
  size = 10,
  color = "#7f7f7f"
)

plot_ly(n, x = OppLoss, y = City, name = OppLoss, mode = "markers", marker = list("pink")) %>% layout(xaxis = f, yaxis = f)

Nothing really changes the x-axis or y-axis. Not sure what I am doing wrong.


回答1:


Just play with the margin. Consider this:

m = list(
  l = 200,
  r = 40,
  b = 100,
  t = 50,
  pad = 0
) 

plot_ly(n, x = OppLoss, y = City, name = OppLoss, mode = "markers", marker = list("pink")) %>% 
layout(autosize = F, margin = m)


来源:https://stackoverflow.com/questions/36432124/x-axis-gets-hidden-in-plotly-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!