Skip to content

Instantly share code, notes, and snippets.

View DanielGoldfarb's full-sized avatar
🙂

Daniel Goldfarb DanielGoldfarb

🙂
View GitHub Profile
@LouisAmon
LouisAmon / json_to_gzip.py
Created July 26, 2018 12:49
How to compress JSON-able data using gzip (Python 3)
import json
import gzip
def compress_data(data):
# Convert to JSON
json_data = json.dumps(data, indent=2)
# Convert to bytes
encoded = json_data.encode('utf-8')
# Compress
compressed = gzip.compress(encoded)
@CMCDragonkai
CMCDragonkai / Matplotlib Backends.md
Last active February 12, 2023 13:22
Matplotlib Backends #matplotlib #python

Matplotlib Backends

Matplotlib is a plotting library. It relies on some backend to actually render the plots. The default backend is the agg backend. This backend only renders PNGs. On Jupyter notebooks the matplotlib backends are special as they are rendered to the browser. Generally you will not need to explicitly set the backend on a Jupyter notebook. This does introduce a discrepancy between code that runs in Jupyter and code that runs as a script natively in the Python interpreter. So you need to understand that the 2 environments are not the same

@ax3l
ax3l / matplotlib.md
Last active October 11, 2019 00:07
Matplotlib: Axes vs Axis vs Figure vs ...