I am trying to rasterize the fancy arrows drawn by the lovely streamplot() function, but am running into major problems since the arrows are drawn at a very late stage (to preserve their aspect ratio).
-------------- from pylab import * fig = figure(figsize=(10,5)) x = linspace(-1,1,10)[:, None] x = linspace(-1,1,10)[:, None] y = x.T # Why don't the first two work... it is annoying. Is it a "bug" or a feature? #s = streamplot(x, y, x+0*y, y+0*x) #s = streamplot(x.flat, y.flat, x+0*y, y+0*x) s = streamplot(x.ravel(), y.ravel(), x+0*y, y+0*x, density=0.5, arrowstyle='->', arrowsize=2.0) setp(s.lines, rasterized=True) # This works fine. setp(s.arrows, rasterized=True) # This has no effect (bug?) setp(s.arrows, visible=False) # This also has no effect (bug?) # Let's get the patches instead ax = gca() #setp(ax.patches, rasterized=True) # The FancyArrowPatchs are here # This does not rasterize the arrows, giving multiple warnings: # UserWarning: Rasterization of 'FancyArrowPatch(...)' will be ignored savefig('tst1.pdf') # How about rasterizing the whole axis ax.set_rasterized(True) savefig('tst2.pdf') # Weird results! (Bug?) Also rasterizes labels. savefig('tst.png') # This works, except that labels rasterized too. ------------ The problem appears to be that FancyArrowPatch objects are transformed late in the game (so that the arrow-heads etc. are in proper proportions), and rasterization seems to need to occur at an earlier stage. The arrows are in the axes, so there is no upper-level container to rasterize them but not the axes labels etc. Rasterizing the axes (tst2.pdf) does rasterize the arrows, but also the labels, and does something really wonky with the plot (the streamlines and axis frame are completely unaligned… most definitely a bug, but I need to track down exactly where this broke or if it has been fixed). Saving to png works, but also rasterizes the labels and ticks which I want to avoid. Is there a robust way to convert the FancyArrowPatch objects to something not-fancy at some point once I have fixed the size of the axis, figure etc. so that I can then rasterize the appropriate elements only? Are the other behaviours noted in the comments bugs (in which case I will open some incidents)? Thanks, Michael. ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users