Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Plotly(R中)中关于“的错误消息”;标记”;_R_Plotly - Fatal编程技术网

Plotly(R中)中关于“的错误消息”;标记”;

Plotly(R中)中关于“的错误消息”;标记”;,r,plotly,R,Plotly,代码块 library(plotly) library(tidyverse) my_fav_graph_SO <- function(my_df, my_levels) { x_axis <- list( title = "Variable Name", range = my_levels) primary_y_axis <- list( title = "coeff") p <- plot_ly() %>%

代码块

library(plotly)
library(tidyverse)

my_fav_graph_SO <- function(my_df, my_levels) 
{

  x_axis <- list(
    title = "Variable Name",
    range = my_levels)

  primary_y_axis <- list(
   title = "coeff")

    p <- plot_ly() %>%

    add_lines(x = ~ my_df$factor_level,
              y = ~ my_df$coeff,
              yaxis = primary_y_axis,
              marker = list(color = "blue")) %>%

    layout(
      title = "graph",
      xaxis = x_axis,
      yaxis = primary_y_axis)

  p
}

df <- data.frame(factor_level = c("Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"),
                 exposure = c(50, 70, NA, 40, 45, 78, 42, 22, 28, 49, 50, 31),
                 coeff = c(1.1, 1.2, NA, 1.3, 1.8, 1.6, 1.4, 1.3, 1.2, 1.1, 1.5, 1.3))

my_levels = c("Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces")

df$factor_level <- factor(df$factor_level, levels = my_levels)

my_fav_graph_SO(df, my_levels)
library(plotly)
图书馆(tidyverse)

my_fav_graph_SO您正在通过
添加线添加线跟踪,但通过
marker=list(color=“blue”)
指定标记颜色。将
标记
更改为
让您摆脱警告:

library(plotly)
library(tidyverse)

my_fav_graph_SO <- function(my_df, my_levels) 
{

  x_axis <- list(
    title = "Variable Name",
    range = my_levels)

  primary_y_axis <- list(
    title = "coeff")

  p <- plot_ly() %>%

    add_lines(x = ~ my_df$factor_level,
              y = ~ my_df$coeff,
              yaxis = primary_y_axis,
              line = list(color = "blue")) %>%

    layout(
      title = "graph",
      xaxis = x_axis,
      yaxis = primary_y_axis)

  p
}

df <- data.frame(factor_level = c("Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"),
                 exposure = c(50, 70, NA, 40, 45, 78, 42, 22, 28, 49, 50, 31),
                 coeff = c(1.1, 1.2, NA, 1.3, 1.8, 1.6, 1.4, 1.3, 1.2, 1.1, 1.5, 1.3))

my_levels = c("Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces")

df$factor_level <- factor(df$factor_level, levels = my_levels)

my_fav_graph_SO(df, my_levels)
library(plotly)
图书馆(tidyverse)

我最喜欢的图表,所以无法回答,但可能会给你一个提示请看下面我的答案-老问题,所以不会通知。