Giter VIP home page Giter VIP logo

alphabet_5x7_dot_matrix's Introduction

Alphabet uses matplothlib to draw a custom message in a 5x7 dot matrix per character

The user can enter upto three lines of text and the result will be matplotlib figure with the text printed in a 5x7 led-like dot-matrix (like the ones used to disply messages on the streets).

Examples

How it works:

  • Enter the text you want to display inside single quotes:
    • text = ['You', 'are welcome', 'to try', 'your own text']
    • Text between each pair of single quotes represents a line
    • Each character is represented in one subplot
    • The amount of words/lines is limited based on matplotlib capabilities or the system running it.

The logic behind:

  • python 3.7 string.printable contains 100 characters:
    • '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ \t\n\r\x0b\x0c'
  • the last few characters are not visible when printed on my display:
    • space ' ' [index 94]
    • tab '\t'
    • linefeed '\n'
    • return '\r'
    • formfeed '\x0b'
    • vertical tab '\x0c' [index 99]
    • These will print an empty plot
  • a dataframe is loaded with the pre-defined (x, y) coordinates for each one of the charaters.
    • how these coordinates where built can be seen in the excel file on this repository.
  • loading a list of values into pandas is achieved by adding a ';' betweent the x and y values and using it as separator when reading the file
  • The x and y columns need to be converted to list using literal_eval otherwise these will be considered as strings when loaded from csv. converters={'x' : eval, 'y' : eval}
  • A figure with dimensions rows * columns (text_lines * longest_text_line) is created
  • The text is scanned line by line, char by char and string.printable is used to find the index for that character.
  • The index from string.printable is the same as the index in the DataFrame. Using this index the (x, y) coordinates are located in the DataFrame and made available to be plot.
  • Using matplotlib the charater is plotted on it's repective space.

Note: the color for each character is random based on the colors list. - Intentionally the white 'wand yellowyare removed from the random selectionrandom.randint(0, len(colors)-3)` as these are hard to see when the background is white or light.

  • If you want to use a single color for all the characters, you can remove the # on this line #font_color = 'k' and set your favorite color

  • Want to save the text to a file? remove the # from the line #plt.savefig

  • Want to customize the markers... see matplotlib.markers and the last cells for an example

  • There are some custom "figures" loaded in the dataframe index 100+ these cannot be indexed by string.printable, are here to play with. see last cells on this book

alphabet_5x7_dot_matrix's People

Contributors

feapri avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.