Skip to content

Instantly share code, notes, and snippets.

View tkshnkmr's full-sized avatar

tkshnkmr

  • London, UK
View GitHub Profile
import numpy as np
import matplotlib.pyplot as plt
# Input x, output y
x = np.linspace(0, 2*np.pi, 400)
y = np.sin(x**2)
# Plot
plt.plot(x, y)
# Change the fontsize of ticks
plt.xticks(fontsize=8)
import numpy as np
import matplotlib.pyplot as plt
# Input x, output y
x = np.linspace(0, 2*np.pi, 400)
y = np.sin(x**2)
# Creates fig and ax from subplots().
# But only create a single plot
fig, ax = plt.subplots()
import numpy as np
import matplotlib.pyplot as plt
# Input x, output y
x = np.linspace(0, 2*np.pi, 400)
y = np.sin(x**2)
# make multiple subplots.
# you can define the size of figure and dpi (dot per inch, defalt dpi=72)
my_dpi = 50
import numpy as np
import matplotlib.pyplot as plt
# Input x, output y
x = np.linspace(0, 2*np.pi, 400)
y = np.sin(x**2)
# Creates figure first
my_dpi = 40
fig = plt.figure(figsize=(20, 10), dpi=my_dpi)
import numpy as np
import matplotlib.pyplot as plt
# Input x, output y
x = np.linspace(0, 2*np.pi, 400)
y = np.sin(x**2)
# Creates figure first
my_dpi = 200
fig = plt.figure(figsize=(4, 2), dpi=my_dpi)
import numpy as np
import matplotlib.pyplot as plt
# image modules
from PIL import Image
import matplotlib.image as mpimg
import cv2
# PyTorch
import torch
from torch.utils import data
from torchvision import transforms