X轴隐藏在Plotly中-R [英] X-axis gets hidden in Plotly - R

查看:155
本文介绍了X轴隐藏在Plotly中-R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我使用了以下代码:

 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)

什么都没有真正改变x轴或y轴.不知道我在做什么错.

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

推荐答案

只需要边距即可.考虑一下:

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)

这篇关于X轴隐藏在Plotly中-R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆