2019-08-28
Easily plot graphs in your website using Plotly + Python

For the last few days I have been scratching my head. How do you plot all the data in your django website, without having to figure out D3 or any other complicated graphing libraries?

I've looked at several solutions, including Djangos Graphos, Chartit, NVD3… Everyone online seems to be recommending to use charting libraries off of this list: https://djangopackages.org/grids/g/charts/

It's frustrating to try many solutions to find out that they are all too complicated to understand, and the copy+paste approach doesn't work most of the time.

However, one good thing came out of this process. I discovered that Plotly is now open-source! Years ago I once played around with Plotly's graphing library, marveling at it's ease of use and admiring it's beauty, however to use it in the past we had to make our plots public for all to see and store them on Plotly's servers. This limited how I could use Plotly in my projects, but that limit isn't on Plotly anymore. Now we can use Plotly just like any other library in Python, Javascript, and other programming languages.

Today I will show you how absolutely easy it is to plot graphs in Django using Plotly's Python API. We are going to make a simple interactive plot that looks like this:

Plotly plot

Read More

2019-08-18
Super Easy Python CLI with Click

Many people who use python are used to the scriptfile workflow, where you write a rigid script in python and run it, somewhat similar to how people use bash scripts.

  1. You find an answer in a blog somewhere that describes how to do something in python
  2. You draft up a python script for the task and get it to work
  3. You hard-code all the parameters the script needs

Don't get me wrong – drafting up python scripts to prototype your idea is really useful. You get your idea working fast, even if your code becomes messy and unmaintainable.

However, wouldn't you like your python script to be as elegant and usable as all the command-line utilities you're used to?

Read More

2019-08-10
Readably Display Arbitrary Python Data

For a CLI program, or any program with text output, many programmers have been challenged with displaying data in the terminal in a readable format.

Either you are making a script to display data from a database via the python module sqlalchemy, or you are displaying the results of a RESTful API call via the python module requests, you likely have a handful of arbitrary complex python data structures to display. These might be a set of lists, dicts, ints, datetimes, and other objects.

Follow this guide and lets code together a way to display this data in a way you can easily read from the terminal.

Read More

2019-08-03
Implementing a Photo Stylizer in Python using a QuadTree Algorithm

So recently, I discovered a project done by Michael Fogleman called Quadtree Art. It inspired me to try and code my own version of the project. This is what I will talk about in this article, how to implement your own Quadtree art program, just as I've done here: github.com/ribab/quadart

QuadArt

Read More