I have the following R code which I can run in R Studio to generate a CDH dendogram plot and save it locally as a SVG.
c1 <- hclust(as.dist(subs_matrix), method = "ward.D2") #ward.D2
#scale the branches of the tree, only changes the aesthetics the dendrogram for interpretation
min_height<-min(c1$height) - 0.01 #Ensure tree has some height at its lowest point
max_height<-max(c1$height)
c1$height <- (c1$height-min_height)/(max_height-min_height)
#plot the tree, cex is the label font size and hang = -1 roots the branches
plot(c1,cex = 0.6, hang = -1, width=20, height = 8)
#Outputs the tree image to a file
dev.print(svg, file = "C:/Users/Users/c3523186/Downloads/plot.svg", width = 20, height = 8)
dev.off()
When running in Databricks however, I don't know if/how I'm able to save the svg, either locally or in the Filestore. The plot produced by Databricks is shown as an image, which is too low quality / not scalable.
Can anyone help? Some research suggests it might have something to do with display_HTML(), but I have no idea how.