图上的多个Y轴未对齐 [英] Multiple Y-axis on graph not aligned

查看:98
本文介绍了图上的多个Y轴未对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过R的Plotly库创建了一个图形. 该图具有2个y轴,并且所有内容看起来都不错,但y轴未对齐. 如何重新对齐"它?

I created a graph through R's Plotly library. The graph has 2 y-axis's and everything looks fine, except that the y-axis's are misaligned. How do I "realign" it?

推荐答案

layout函数中,您可以手动设置轴范围.您可以使用它来对齐它们.通常,两条迹线的大小会非常不同.

In the layout function, you can set axis ranges manually. You can use this to align them. Often, the scale of your two traces will be very different, though.

plot_ly(...) %>%
add_trace(..., yaxis = "y2") %>%
layout(
  yaxis = list(
    range = c(-2, 2)
  ),
  yaxis2 = list(
    range = c(-2, 2)
  )
)

这篇关于图上的多个Y轴未对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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