Sharing your visualizations with others

Introduction to Data Visualization with Matplotlib

Ariel Rokem

Data Scientist

A figure to share

fig, ax = plt.subplots()

ax.bar(medals.index, medals["Gold"])
ax.set_xticklabels(medals.index, rotation=90)
ax.set_ylabel("Number of medals")

plt.show()

Introduction to Data Visualization with Matplotlib

Saving the figure to file

fig, ax = plt.subplots()

ax.bar(medals.index, medals["Gold"])
ax.set_xticklabels(medals.index, rotation=90)
ax.set_ylabel("Number of medals")

fig.savefig("gold_medals.png")
ls
gold_medals.png
Introduction to Data Visualization with Matplotlib

Different file formats

fig.savefig("gold_medals.jpg")
fig.savefig("gold_medals.jpg", quality=50)
fig.savefig("gold_medals.svg")
Introduction to Data Visualization with Matplotlib

Resolution

fig.savefig("gold_medals.png", dpi=300)
Introduction to Data Visualization with Matplotlib

Size

fig.set_size_inches([5, 3])

Introduction to Data Visualization with Matplotlib

Another aspect ratio

fig.set_size_inches([3, 5])

Introduction to Data Visualization with Matplotlib

Practice saving your visualizations!

Introduction to Data Visualization with Matplotlib

Preparing Video For Download...