You can probably achieve an adequately similar effect with a gradient. If you remove it, your SVG file is en par with your JPEG. This is responsible for about of the file size. You can then control the dpi of the rasterized elements using dpi=300 (or whatever dpi you want) when you fig.savefig.Ĭonsider the following: import matplotlib.pyplot as pltįigV, axesV = plt.subplots(nrows=10, ncols=5)įigR, axesR = plt.subplots(nrows=10, ncols=5)Īx.scatter(range(3000), range(3000), rasterized=True)īigscatterV.svg has a file size of 16MB, while bigscatterR.svg has a file size of only 250KB. Your SVG contains an embedded pixel graphic for the shade in the bottom right of the controller. You can do this by setting rasterized=True when calling ax.scatter. This can dramatically reduce the file size, and if you set the dpi high enough, you probably won't lose any useful information from the plot. While not ideal, one potential option is to rasterize only the data points created by ax.scatter, and leave the axes, labels, titles, etc. If you want to keep all the data points as vector graphics, its unlikely you'll be able to reduce the file size.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |