r - R plot_ly hoverinfo
问题描述
我在一个闪亮的应用程序中使用 plot_ly。我有以下功能
plot_ly(df, x = ~x, y = ~y , key = df$id, type='scatter', mode="markers",
name = "Clusters", opacity = point.opacity, text = df$id, hoverinfo = "text")
如果df$id的长度不为 0,那么一切都很好。如果长度为 0,因为没有可用数据,我会收到以下错误:Error in : Column 'hoverinfo' must be length 0, not 1
. 如果我省略 hoverinfo,那么空数据集一切正常。
我怎样才能解决这个问题?我尝试使用 ifelse 但这不起作用。我的解决方案是定义一个 if 语句,然后在有或没有 hoverinfo 的情况下调用 plot_ly。有人有更好的主意吗?
解决方案
推荐阅读
- java - jmeter如何控制用户、请求和吞吐量?
- python - 将数据的 3D 张量从极坐标转换为笛卡尔坐标
- html - 未找到:/在 pythonanywhere 上部署项目时出错
- computer-science - 不是函数的值的术语是什么?
- java - 在构造函数中使用枚举映射时出现错误“类 ResourceDto 中的构造函数 ResourceDto 不能应用于给定类型”
- javascript - Javascript 变量必须访问一次才能访问它的值
- flutter - 我在颤动中找不到设备文件资源管理器
- c++ - 通过像素格式转换将 AVFrame 转换为 QImage
- android - Android 中的 CountDownTimer 无法正常工作
- python - 如何在使用 Pandas/Numpy 扩展窗口时使用 groupby?