Skip to content
Advertisement

Multiple color argument in plotly in python

JavaScript

My objective is make a bar plot in plotly.

I did

JavaScript

I get

enter image description here

I want Type A & Type B to have different colors, and preferable additional separate legend. I tried:

JavaScript

but this gives error.

Advertisement

Answer

Using color to illustrate two different dimensions of your data would, in my opinion, quickly become very confusing. Unless you were able to use different shades of the same color. But even that would become messy with many categories. Luckily, plotly now provides another way to highlight multiple dimensions, namely Patterned Bar Charts with Plotly Express:

JavaScript

Plot 1

enter image description here

And you can change how the bars are grouped or stacked through barmode:

JavaScript

Plot 2

enter image description here

Complete code

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