![]() However it is the second example (where we are scaling area) that doubling area appears to make the circle twice as big to the eye. Similarly the second example each circle has area double the last one which gives an exponential with base 2. The question asked about doubling the width of a circle so in the first picture for each circle (as we move from left to right) it's width is double the previous one so for the area this is an exponential with base 4. Now the apparent size of the markers increases roughly linearly in an intuitive fashion.Īs for the exact meaning of what a 'point' is, it is fairly arbitrary for plotting purposes, you can just scale all of your sizes by a constant until they look reasonable.Įdit: (In response to comment from probably confusing wording on my part. If instead we have # doubling the area of markers Notice how the size increases very quickly. To see this consider the following two examples and the output they produce. Because of the scaling of area as the square of width, doubling the width actually appears to increase the size by more than a factor 2 (in fact it increases it by a factor of 4). There is a reason, however, that the size of markers is defined in this way. This means, to double the width (or height) of the marker you need to increase s by a factor of 4. Img = img.reshape(_width_height() + (3,))įor x, y, c in zip(,, ):įig = plt.figure(figsize=figsize, dpi=dpi, tight_layout=".This can be a somewhat confusing way of defining the size but you are basically specifying the area of the marker. Img = np.frombuffer(_rgb(), dtype=np.uint8) import numpy as npįrom _agg import FigureCanvasAgg as FigureCanvas Note this solution forfeits access to the original fig object and attributes, so any other modifications to figure should be made before it's drawn. I opted to instead plot each layer separately with alpha=1 and then read in the resulting image with np.frombuffer (as described here), then add the alpha to the whole image and plot overlays using plt.imshow. I also wanted to plot a different shape other than a circle. I had to plot >500000 points, and the shapely solution does not scale well. Here's a hack if you have more than just a few points to plot. That means that the separation needs to be chosen based on the range of your data, and if you plan to make an interactive plot then there's a risk of all the data points suddenly vanishing if you zoom out too much, and stretching if you zoom in too much.Īs you can see, I found 1e-5 to be a good separation for data with a range of. If they're two far apart then the separation will be visible on your plot, but if they're too close together, matplotlib doesn't plot the line at all. One caveat is that you have to be careful with the spacing between the two points you use to make each circle. ![]() Plt.rcParams = 'round'Īx.plot(*expand(x1, y1), lw=20, color="blue", alpha=0.5)Īx.plot(*expand(x2, y2), lw=20, color="red", alpha=0.5)Īnd each color will overlap with the other color but not with itself. With that in mind, you can do this: import numpy as np You see while Matplotlib plots data points as separate objects that can overlap, it plots the line between them as a single object - even if that line is broken into several pieces by NaNs in the data. This is a terrible, terrible hack, but it works. Polygon2 = ptc.Polygon(np.array(polygon2.exterior), facecolor="blue", lw=0, alpha=alpha) Polygon1 = ptc.Polygon(np.array(polygon1.exterior), facecolor="red", lw=0, alpha=alpha) Polygons2 =, y2).buffer(size) for i in range(n)]Īx = fig.add_subplot(111, title="Test scatter") ![]() Polygons1 =, y1).buffer(size) for i in range(n)] Here is the code : import matplotlib.pyplot as plt You can get this scatterplot with Shapely. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |