Skip to content
Advertisement

How to fix transparency overlaps in Matplotlib when plotting multiple figures?

I have a function that inputs a string (the name of the dataframe we’re visualizing) and returns two histograms that visualize that data. The first plot (on the left) is the raw data, the one on the right is it after being normalized (same, just plotted using the matplotlib parameter density=True). But as you can see, this leads to transparency issues when the plots overlap. This is my code for this particular plot:

JavaScript

What my current plot looks like

Any ideas on how to make the colors blend a bit better would be helpful. Alternatively, if there are any other combinations you know of that would work instead, feel free to share. I’m not picky about the color choice. Thanks!

Advertisement

Answer

I think it is better to emphasize such a histogram by distinguishing it by the shape of the histogram or by the difference in transparency rather than visualizing it by color. I have coded an example from the official reference with additional overlap.

JavaScript

enter image description here

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