Possible to render points plotted in Python with Matplotlib using a blending mode?

江枫思渺然 提交于 2020-05-10 20:52:09

问题


I'm plotting a series of overlapping points of various sizes using matplotlib in order from largest to smallest (smallest on top) but I am wondering if it is possible to configure the points to draw using a soft light blending mode so that you can see through stacks of points without using alpha blending.

I'm loading my data using pandas and then plotting using the pandas plotting function (which uses matplotlib) like this simplified example:

import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt

roads = gpd.read_file('roads.shp')
points = gpd.read_file('points.shp')

f, ax = plt.subplots()

roads.plot(ax=ax, linewidth=.5, color='#2D1B1B', zorder=1)
points.plot(ax=ax, column='color', markersize=size, zorder=2)

plt.axis('equal')
plt.show()

Here's how the plot looks:

(I have exaggerated the overlap)


Here's how I would like it to look:

In this example each point is blended using a soft light blending mode, which makes it possible to 'see through' each point a bit without desaturating or adding transparency to points which are overlapping white. This makes it easy to see the larger, darker colored circles in the middle, without making the smaller, lighter colored circles on the white background harder to see the way alpha blending would.


Difference from Alpha Blending:

The most common method for blending overlapping points like this is to just make them transparent so that the overlapping points add up to a more intense color, but while this is desirable for visualizing density, it does not make sense in this context and looks washed out and bad:


Is it possible to plot points using a soft light blending mode in matplotlib?

来源:https://stackoverflow.com/questions/50285019/possible-to-render-points-plotted-in-python-with-matplotlib-using-a-blending-mod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!