X 轴隐藏在 Plotly - R 中

X-axis gets hidden in Plotly - R

我正在使用plotly。我制作的每张图都隐藏了一半的 x 轴。即使我将 x 轴的变量用作 y 轴,也会发生这种情况。例如,考虑以下数据集:

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")

我使用了以下代码:

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

条形图、折线图等也是如此。我尝试使用以下代码更改设置:

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)

没有真正改变 x 轴或 y 轴。不确定我做错了什么。

玩一下边距吧。考虑一下:

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)