如何在 R-plotly 等高线图中添加 X 标签、Y 标签、z 标签
How to add X label, Y label, z label in R-plotly contour plot
我使用 R-plotly 创建了等高线图。不幸的是,我无法在等高线图上添加图的标题、x 轴标题和 y 轴标题。我还想将 Z 标签(位置 name/sample ID)合并到图中。 body 可以帮我添加这些吗?我的数据框包含 x=latitude、y=longitude、chla=Z,它是从 6 个位置收集的。我的代码如下
install.packages ("plotly")
library(plotly)
df<-read.csv("contour_Jan20.csv",head=T)
df
fig <- plot_ly(df,x= df$Lat, y=df$Long, z=df$Chl,
z = ~volcano, type = "contour", contours = list(showlabels = TRUE)
)
fig <- fig %>% colorbar(title = "Concentration \n in mg/L")
fig
这是一个使用 mtcars
-
的例子
library(plotly)
fig <- plot_ly(mtcars,x= ~mpg, y=~disp, z=~am, type = "contour",
contours = list(showlabels = TRUE))
fig <- fig %>%
colorbar(title = "Concentration \n in mg/L") %>%
layout(title = 'Title of the plot', plot_bgcolor = "#e5ecf6")
fig
fig <- plot_ly(mtcars,x= ~mpg, y=~disp, z=~am, type = "contour",
contours = list(showlabels = TRUE))
t <- list(
family = "Courier New",
size = 14,
color = "blue")
t1 <- list(
family = "Times New Roman",
color = "red"
)
t2 <- list(
family = "Courier New",
size = 14,
color = "green")
t3 <- list(family = 'Arial')
fig <- fig %>%
colorbar(title = "legend title", font =t2) %>%
layout(title = 'Plot title', font =t1,
plot_bgcolor = "#e5ecf6",xaxis = list(title = "X title", font = t3),
yaxis = list(title = "y title", font = t3))
fig
我使用 R-plotly 创建了等高线图。不幸的是,我无法在等高线图上添加图的标题、x 轴标题和 y 轴标题。我还想将 Z 标签(位置 name/sample ID)合并到图中。 body 可以帮我添加这些吗?我的数据框包含 x=latitude、y=longitude、chla=Z,它是从 6 个位置收集的。我的代码如下
install.packages ("plotly")
library(plotly)
df<-read.csv("contour_Jan20.csv",head=T)
df
fig <- plot_ly(df,x= df$Lat, y=df$Long, z=df$Chl,
z = ~volcano, type = "contour", contours = list(showlabels = TRUE)
)
fig <- fig %>% colorbar(title = "Concentration \n in mg/L")
fig
这是一个使用 mtcars
-
library(plotly)
fig <- plot_ly(mtcars,x= ~mpg, y=~disp, z=~am, type = "contour",
contours = list(showlabels = TRUE))
fig <- fig %>%
colorbar(title = "Concentration \n in mg/L") %>%
layout(title = 'Title of the plot', plot_bgcolor = "#e5ecf6")
fig
fig <- plot_ly(mtcars,x= ~mpg, y=~disp, z=~am, type = "contour",
contours = list(showlabels = TRUE))
t <- list(
family = "Courier New",
size = 14,
color = "blue")
t1 <- list(
family = "Times New Roman",
color = "red"
)
t2 <- list(
family = "Courier New",
size = 14,
color = "green")
t3 <- list(family = 'Arial')
fig <- fig %>%
colorbar(title = "legend title", font =t2) %>%
layout(title = 'Plot title', font =t1,
plot_bgcolor = "#e5ecf6",xaxis = list(title = "X title", font = t3),
yaxis = list(title = "y title", font = t3))
fig