How do I annotate heat maps in plotly?
Code:qtr1 = yq(“2006q1”)
qtr2 = yq(“2007q1”)
qtrs= seq(qtr1,qtr2,by=“quarter”)
tester=indflows$new(j2jod,ind1,ind2,geo1,geo2,qtr1)
tester2=indflows$new(j2jod,ind1,ind2,geo1,geo2,qtr2)
tester3=indflowsdiff$new(tester,tester2)
plotflow = function(flowobj,varname){
p=plot_ly(type=“heatmap”,
colors = colorRamp(c(“red”, “blue”)),
z=eval(parse(text=paste(“flowobj$vardata”,"$",varname,sep=""))),
x=factor(flowobj$alldata[[1]]$industry),
y=factor(flowobj$alldata[[1]]$industry_orig)) %>%
layout(title=“Title”,
showlegend = FALSE,
xaxis=list(title=“x-axis”),
yaxis=list(title=“y-axis”))
y = flowobj$qtr
return§
}
plotflowqtrs = function(df,ind1,ind2,geo1,geo2,qtrs){
Get Data
data=lapply(qtrs,indflows$new,df=df,inddest=ind1,indorig=ind2,geodest=geo1,geoorig=geo2)
p=lapply(data,plotflow,varname=“ee”)
subplot(p,nrows = round(length(qtrs)/3, digits=0), margin = 0.025)
}
pfqvsbase = function(df,ind1,ind2,geo1,geo2,qtrbase,qtrs){
Get Data
base=indflows$new(df,ind1,ind2,geo1,geo2,qtrbase)
data=lapply(qtrs,indflows$new,df=j2jod,inddest=ind1,indorig=ind2,geodest=geo1,geoorig=geo2)
diff=lapply(data,indflowsdiff$new,x=base)
p=lapply(diff,plotflow,varname=“ee”)
subplot(p,nrows = round(length(qtrs)/3, digits=0), margin = 0.025)
}
qtrbase = yq(“2006q1”)
pfqvsbase(j2jod,ind1,ind2,geo1,geo2,qtrbase,qtrs)
base=indflows$new(j2jod,ind1,ind2,geo1,geo2,qtrbase)
pfqdelta = function(df,ind1,ind2,geo1,geo2,qtrs){
}
image of my plot: