2

I'm currently plotting some data using the plotly R library for the plot type treemap.

When plotting the data, I get a big top border (and smaller ones on right, left and bottom) as visible in this example Treemap Plotly

I would like to eliminate these borders, in order to have something similar to this Treemap without borders

Is there a way to do this?

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214

1 Answers1

0

The borders can be removed by combing a zero line width with zero tile padding.

Here's an example that Plotly has put on their site with the standard borders.

# example from at https://plotly.com/r/treemaps/
plot_ly(
  type="treemap",
  labels=c("Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"),
  parents=c("", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve")
)

enter image description here

Here is the same plot without borders.

# no borders
plot_ly(
  type="treemap",
  labels=c("Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"),
  parents=c("", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve"),
  marker = list(line = list(width = 0)),
  tiling = list(pad = 0))

enter image description here

Kat
  • 15,669
  • 3
  • 18
  • 51
  • Thanks for your answer @Kat . In fact, the problem is, that the parent category title takes space, which is not accounted in the sum of the children. In the question's solution, this issue is resolved, by adding the name of the children in the bottom edge, while the parents name (and defining color) is in the top left edge. – Jonas Schnidrig May 17 '22 at 14:41
  • Perhaps if you shared your data and your code I could help a bit more. Check it out: [making R reproducible questions](https://stackoverflow.com/q/5963269). – Kat May 17 '22 at 14:49
  • How can I make it so that Enoch fills up more of the awan square (the borders seem too big). – Trevor Sep 25 '22 at 04:57