Skip to content
Advertisement

How to plot a horizontal Stacked bar plot using Plotly-Python?

I’m trying to plot the below summary metric plot using plotly.

enter image description here

data

JavaScript
JavaScript

So far, I’m able to plot this

enter image description here

I’m unable to add Model Names to the plot. How add Model column as Legend and add all model values into the plot?

Advertisement

Answer

  • shape the data frame first df2 = df.set_index("Model").unstack().to_frame().reset_index()
  • then it’s a simple case of using Plotly Express
JavaScript

enter image description here

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement