Skip to content

Instantly share code, notes, and snippets.

@iancze
Created October 12, 2020 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iancze/09b83f9f27b179e63e3c688881761b63 to your computer and use it in GitHub Desktop.
Save iancze/09b83f9f27b179e63e3c688881761b63 to your computer and use it in GitHub Desktop.
Matplotlib rasterized=True demonstration.
import matplotlib.pyplot as plt
import numpy as np
n = 100000
x = np.random.normal(size=n)
y = np.random.normal(size=n)
pkw = {"marker": "o", "alpha": 0.1, "mew": 0, "ms": 2, "ls": ""}
fig, ax = plt.subplots(nrows=1)
ax.plot(x, y, **pkw)
ax.set_aspect("equal")
plt.savefig("scatter.pdf")
fig, ax = plt.subplots(nrows=1)
ax.plot(x, y, "o", **pkw, rasterized=True)
ax.set_aspect("equal")
plt.savefig("scatter-rasterized.pdf", dpi=600)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment