How to do a scatter plot with empty circles in Python?

From the documentation for scatter: Optional kwargs control the Collection properties; in particular: edgecolors: The string ‘none’ to plot faces with no outlines facecolors: The string ‘none’ to plot unfilled outlines Try the following: import matplotlib.pyplot as plt import numpy as np x = np.random.randn(60) y = np.random.randn(60) plt.scatter(x, y, s=80, facecolors=”none”, edgecolors=”r”) plt.show() Note: … Read more

matplotlib scatter plot colour as function of third variable [duplicate]

This works for me, using matplotlib 1.1: import numpy as np import matplotlib.pyplot as plt x = np.arange(10) y = np.sin(x) plt.scatter(x, y, marker=”+”, s=150, linewidths=4, c=y, cmap=plt.cm.coolwarm) plt.show() Result: Alternatively, for n points, make an array of RGB color values with shape (n, 3), and assign it to the edgecolors keyword argument of scatter(): … Read more

MPI partition matrix into blocks

What you’ve got is pretty much “best practice”; it’s just a bit confusing until you get used to it. Two things, though: First, be careful with this: sizeof(MPI_CHAR) is, I assume, 4 bytes, not 1. MPI_CHAR is an (integer) constant that describes (to the MPI library) a character. You probably want sizeof(char), or SIZE/2*sizeof(char), or … Read more

Scale matplotlib.pyplot.Axes.scatter markersize by x-scale

Using Circles An easy option is to replace the scatter by a PatchCollection consisting of Circles of radius 0.5. circles = [plt.Circle((xi,yi), radius=0.5, linewidth=0) for xi,yi in zip(x,y)] c = matplotlib.collections.PatchCollection(circles) ax.add_collection(c) Using scatter with markers of size in data units The alternative, if a scatter plot is desired, would be to update the markersize … Read more

Matplotlib scatterplot; color as a function of a third variable

There’s no need to manually set the colors. Instead, specify a grayscale colormap… import numpy as np import matplotlib.pyplot as plt # Generate data… x = np.random.random(10) y = np.random.random(10) # Plot… plt.scatter(x, y, c=y, s=500) plt.gray() plt.show() Or, if you’d prefer a wider range of colormaps, you can also specify the cmap kwarg to … Read more