我正在使用plotly将一个数据集可视化为可在仪表板中的shiny应用程序中使用的交互式图。我使用plotly软件包,因为它似乎非常适合我做这样的事情。我想创建具有线和标记的图。当尝试使用以下代码进行跟踪时,我只得到了标记,没有它们之间的线。
plot_ly(cube_eduexpgdp, x = ~year) %>%
add_trace(y = ~expenditure_gdp, mode = "lines+markers",
color = ~country_name, line = list(shape = "linear")) %>%
layout(title = "Government expenditures as percentage of GDP",
yaxis = list(title = "Expenditures (%)"),
xaxis = list(title = "Year"))
Plotly的教程建议使用以下代码进行操作。当我使用此代码时,画布为空,但在悬停时会显示分组数据点的值。
plot_ly(cube_eduexpgdp, x = ~year, y = ~expenditure_gdp,
color = ~country_name) %>%
add_lines() `
有人能帮我吗?非常感谢!