-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
matplotlib markers? #2
Comments
This is strange, I get much different run times: My code
Your code
If look at the draw command (i.e. not including imports, etc. which would dilute the difference between the codes) which is what matters if I want to e.g. zoom in/out then using plot seems to be 70 times slower on my computer. I'm using the MacOS X backend though, could that explain the difference? |
Ah. That probably does explain the difference. The Agg backend has an optimization where it draws the marker once as a stamp and then simply alpha-blends that raster into place for each marker instance. The MacOS X backend does not have such an optimization. You may want to try Agg. It may also be worth the moderate amount of effort to port this optimization to the Mac OS-X backend -- it's difficult for me to do this without access to a Mac, of course. |
Sorry to revive this thread after ~a year. I just wanted to get @mdboom's attention :) @mdboom, would Agg allow for a similar optimization in the MPL draw_path_collection call? That is, is it possible within Agg to draw a master marker image once, and then possibly resize and recolor that rasterized image? I understand the resized markers might not be accurate at the pixel-level, but I'd be willing to sacrifice some aesthetics for ~50x performance boost ( |
@mdboom @ChrisBeaumont - I'm going to close this: the code here has evolved a bit since it started off, and the performance is higher than what can be done with the various backends, and allows for the colormap-coding (which |
Have you considered using markers for this? Replacing the rasterized scatter calls in example.py with:
ax.plot(x, y, '+', markersize=2, markeredgecolor='red', antialiased=False)
runs in about 2.1s, on my machine. rasterized_scatter runs in about 1.9s, so it is slightly faster, but not by much.
The interactive performance of matplotlib markers is actually better because it isn't reallocating an image buffer on each pan and zoom.
About the only time to use scatter over marker is when the size of the symbol changes with each instance.
If rasterized output in the file is what you want, you can call "set_rasterized(True)" on the Line2D objects.
The text was updated successfully, but these errors were encountered: