You can find more examples of using collections in the matplotlib docs. If you scale the plots, say by changing the axis limits to ax.axis(), then the circles on the right plot scale as desired: The result is what you hope for simple scatter plot on the left, scaled plot on the right: Offsets=offsets, transOffset=ax.transData))Īx.axis('equal') # set aspect ratio to equal Since your data isn't available, I made some up and wrote this code: import matplotlib.pyplot as pltįrom llections import EllipseCollectionįig, ax = plt.subplots(1, 2, figsize=(16, 6),Īx.scatter(x, y, s=size, c=color, cmap=cmap)Īx.add_collection(EllipseCollection(widths=size, heights=size, angles=0, units='xy', If you want to say draw circles that are a given size, you should use the circle command. This size will be independent of the axes, as is the nature of a scatter plot (it doesn't make sense if you narrow in on a region in a scatter plot that the points get bigger). If you set the parameter to 'None', borders are not draw.As far as I know there is not a high-level way to do this, but you can make it work with an EllipseCollection. The pylab.scatter function takes a value size based on the size in points2. These are a matplotlib color argument or a sequence of rgba tuples, respectively. You can get the border of the scatter marks out using the keyword arguments edgecolor or edgecolors. I used z**2 to give colors.įinally for your second question.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |