import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_scatter_density import ScatterDensity
x = [1, 2, 3, 4, 5]
y = [1, 1, 2, 2, 2]
density = [5, 10, 20, 30, 40]
fig, ax = plt.subplots()
sc = ScatterDensity(ax, x, y, density)
cmap = cm.get_cmap('jet', 30) #create a color map using the 'jet' color scheme with 30 different colors
sizes = [20, 40, 60, 80, 100] #a list of five different dot sizes to correspond with the five different density values
sc.scatter(s=100, marker='.', cmap=cmap, sizes=sizes, lw=0)
The sizes
argument in sc.scatter()
specifies the different dot sizes to be used for the different density levels. The s=100
argument sets the default size for the dots in the plot. Adjust the sizes
argument and the s
argument as needed to achieve the desired dot size.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-09-13 11:00:00 +0000
Seen: 11 times
Last updated: Dec 05 '22
What is Fullscreen Activity in Android?
What does 'Invalid argument (callbackUrlScheme): must be a valid URL scheme' mean?
How can SSL passthrough be implemented with Traefik in Kubernetes?
What are the steps to create a semi-circular shape divided into 8 parts using HTML, CSS, or SVG?
What is the way to name parameters and REST API urls in Spring Boot?
How can ASP.NET Core be configured to incorporate various authorization strategies?