bigos lecture 2024-1203

main
Edward Bigos 2024-12-03 10:56:36 -05:00
parent c7f61c0ab4
commit 6f1474023e
11 changed files with 108 additions and 0 deletions

View File

@ -0,0 +1,20 @@
import matplotlib.pyplot as plt
import numpy as np
plt.style.use('_mpl-gallery')
# Make data
n = 100
xs = np.linspace(0, 1, n)
ys = np.sin(xs * 6 * np.pi)
zs = np.cos(xs * 6 * np.pi)
# Plot
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
ax.plot(xs, ys, zs)
ax.set(xticklabels=[],
yticklabels=[],
zticklabels=[])
plt.show()

View File

@ -0,0 +1,24 @@
import matplotlib.pyplot as plt
import numpy as np
plt.style.use('_mpl-gallery')
# make data
x = np.linspace(0, 10, 100)
y = 4 + 1 * np.sin(2 * x)
x2 = np.linspace(0, 10, 25)
y2 = 4 + 1 * np.sin(2 * x2)
print(x)
# plot
fig, ax = plt.subplots()
#ax.plot(x2, y2 + 2.5, 'x', markeredgewidth=2)
ax.plot(x, y, linewidth=2.0)
#ax.plot(x2, y2 - 2.5, 'o-', linewidth=2)
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
ylim=(0, 8), yticks=np.arange(1, 8))
plt.show()

View File

@ -0,0 +1,8 @@
import numpy as np
from numpy import pi
np.linspace(0, 2, 9) # 9 numbers from 0 to 2
x = np.linspace(0, 2 * pi, 100) # useful to evaluate function at lots of points
f = np.sin(x)
print(x)
print(f)

View File

@ -0,0 +1,12 @@
# import EAN13 from barcode module
from barcode import EAN13
# Make sure to pass the number as string
number = '5901234123457'
# Now, let's create an object of EAN13
# class and pass the number
my_code = EAN13(number)
# Our barcode is ready. Let's save it.
my_code.save("new_code")

View File

@ -0,0 +1,15 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# https://stackoverflow.com/questions/57427243/how-to-generate-barcode-in-python-3-7
import barcode
from barcode.writer import ImageWriter
def testEan():
EAN = barcode.get_barcode_class('ean13')
ean = EAN(u'123456789011', writer=ImageWriter())
fullname = ean.save('my_ean13_barcode')
if __name__ == '__main__':
testEan()

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="264" width="264" class="pyqrcode"><path transform="scale(8)" stroke="#000" class="pyqrline" d="M4 4.5h7m1 0h2m1 0h1m2 0h1m3 0h7m-25 1h1m5 0h1m1 0h1m2 0h1m2 0h1m1 0h1m1 0h1m5 0h1m-25 1h1m1 0h3m1 0h1m5 0h2m2 0h1m1 0h1m1 0h3m1 0h1m-25 1h1m1 0h3m1 0h1m1 0h1m1 0h2m2 0h2m2 0h1m1 0h3m1 0h1m-25 1h1m1 0h3m1 0h1m1 0h1m1 0h1m1 0h1m1 0h3m1 0h1m1 0h3m1 0h1m-25 1h1m5 0h1m1 0h2m3 0h2m1 0h1m1 0h1m5 0h1m-25 1h7m1 0h1m1 0h1m1 0h1m1 0h1m1 0h1m1 0h7m-14 1h1m2 0h1m1 0h1m-14 1h1m2 0h1m4 0h4m1 0h1m2 0h3m1 0h2m-25 1h1m1 0h3m2 0h1m1 0h1m2 0h1m1 0h1m1 0h4m3 0h2m-25 1h1m2 0h1m2 0h1m1 0h2m5 0h3m3 0h1m1 0h2m-25 1h1m1 0h1m1 0h1m2 0h1m2 0h2m1 0h1m4 0h3m2 0h2m-25 1h1m1 0h2m1 0h3m1 0h3m1 0h1m2 0h3m2 0h1m2 0h1m-24 1h2m1 0h2m2 0h1m2 0h3m1 0h1m1 0h3m2 0h1m1 0h1m-25 1h1m3 0h4m1 0h3m1 0h1m1 0h2m1 0h3m1 0h1m1 0h1m-24 1h2m1 0h1m2 0h1m1 0h1m2 0h1m3 0h1m2 0h1m1 0h1m2 0h1m-25 1h2m1 0h1m2 0h2m1 0h2m1 0h9m1 0h1m1 0h1m-17 1h3m4 0h2m3 0h1m1 0h1m1 0h1m-25 1h7m2 0h1m2 0h1m3 0h1m1 0h1m1 0h1m2 0h2m-25 1h1m5 0h1m3 0h1m1 0h5m3 0h1m1 0h1m-23 1h1m1 0h3m1 0h1m2 0h2m2 0h1m2 0h6m-22 1h1m1 0h3m1 0h1m1 0h1m3 0h1m1 0h1m4 0h3m1 0h1m-24 1h1m1 0h3m1 0h1m2 0h1m3 0h1m1 0h1m4 0h3m1 0h1m-25 1h1m5 0h1m2 0h1m2 0h2m2 0h2m1 0h2m-21 1h7m3 0h1m2 0h4m1 0h4m1 0h2"/></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,6 @@
# basic_qrcode.py
import segno
qrcode = segno.make_qr("Hello, World")
qrcode.save("basic_qrcode.png")

View File

@ -0,0 +1,21 @@
# Import QRCode from pyqrcode
# from https://www.geeksforgeeks.org/python-generate-qr-code-using-pyqrcode-module/
import pyqrcode
import png
from pyqrcode import QRCode
# String which represents the QR code
#s = "www.geeksforgeeks.org"
s = "cset.stcc.edu"
# Generate QR code
url = pyqrcode.create(s)
# Create and save the svg file naming "myqr.svg"
url.svg("myqr.svg", scale = 8)
# Create and save the png file naming "myqr.png"
url.png('myqr.png', scale = 6)