Python | Vertical Barcode

In this article, we are going to create vertical barcode using matplotlib in Python plotting.
Submitted by Anuj Singh, on August 27, 2020

Illustrations:

Vertical barcode example in python (1)

Vertical barcode example in python (2)

Vertical barcode example in python (3)

Python code for vertical barcode

import matplotlib.pyplot as plt
import numpy as np

# the bar
x = np.random.rand(500) > 0.7

fig = plt.figure()

# a Verticle Barcode
ax = fig.add_axes([0.1, 0.2, 0.1, 0.8])
ax.set_axis_off()
ax.imshow(x.reshape((-1, 1)), aspect='auto', 
          cmap='binary', interpolation='nearest')
ax.set_title('Verticle Barcode Example 1')
plt.show()

##########################################

x = np.random.rand(500) > 0.7

fig = plt.figure()

# a Verticle Verticle Barcode
ax = fig.add_axes([0.1, 0.1, 0.1, 0.8])
ax.set_axis_off()
ax.imshow(x.reshape((-1, 1)), aspect='auto', 
          cmap='binary', interpolation='nearest')
ax.set_title('Verticle Barcode Example 2')
plt.show()

##########################################

x = np.random.rand(500) > 0.7

fig = plt.figure()

# a Verticle Barcode
ax = fig.add_axes([0.1, 0.1, 0.1, 0.8])
ax.set_axis_off()
ax.imshow(x.reshape((-1, 1)), aspect='auto', 
          cmap='binary', interpolation='nearest')
ax.set_title('Verticle Barcode Example 3')
plt.show()

Output:

Output is as Figure



Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.