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