Blog Post, Programming, Tutorials

Building an Interactive Graph using Dash

Making an interactive graph is something that is very useful when performing data analysis, after all if you can’t interpret your data, what use does it have? This blog post will go over an example of a very simple interactive Dash graph for those just getting started with interactive graphing using Dash.

I have been using Excel for data analysis in my work and I was struggling with getting a pivot table to display exactly what I wanted, and how I wanted it. Is that too much to ask??? After trying a few different methods of organizing my data, I moved on to PowerBI, which I had even larger problems with. I already knew of the python library called Dash and I had been wanting to try interactive graphs with it for a while so I decided to give it a go.

It took me a good couple of hours starting from the first tutorial, but I ended up with a basic graph that finally displayed my data how I wanted it. Working with a programming language and knowing that you code the behavior of the graph was very cathartic after struggling with getting Excel and PowerBI to plot the data without summarizing it or combining separate trials into one trace on the graph.

Installing the Necessary Libraries

I will be assuming that you are using Anaconda and their package manager, conda, in this post. You will first need to install the community managed dash repo.

conda install -c conda-forge dash

And that should be it!

Code Overview

We start with the import statements and then load the Excel file containing the data into a dataframe. After this we create the layout of the Dash app and define the callback function which is called anytime the user interacts with the buttons on the user interface. The global dataframe variable is filtered in the callback function depending on what the user chooses using the interface and the subsequent result is graphed. The callback function loops over what the user has chosen in the interface and adds a trace for each to the graph. I made this app by reading the Dash tutorial on plot.ly’s website, here and modifying and creating my own logic for my data.

I decided not to use a css style sheet as my main objective was to create something that is functional for data analysis and as simple as possible.

The Code Itself

Blog Post, Programming, Tutorials

Creating Your First C Program: Quickstart

Many can relate to the challenge of learning a new coding language. I’ve found that quickly being able to make a first program to start experimenting with the language helps inspire the confidence needed to keep going. In this blog post I will be briefly going over the steps needed to create a simple first program in the C language in Ubuntu.

Setting Up Your Development Environment On Your Computer:

  1. Install your favorite text editor; mine happens to be VS Code by Microsoft.
  2. Know how to use the cd and ls commands in the terminal to access the files you will be creating.

C is a compiled language which means that once you have written the .c file you will need to “compile” it which will create another file which the computer will use to run the program.

To install the GCC C compiler on your computer run:

To Create Your First Program:

Create a File with the .c file extension in your text editor. Below is a sample first C file.

To Compile Your First Program:

Move to the directory that contains your program and type:

This code has two important effects, it runs the gcc compiler and creates and names an object file from your program file.

To Run Your First Program:

In the same directory, type:

Please let me know if this helped you to get started quickly with C on Linux.

Blog Post, Programming, Tutorials

Creating your First Clojure Program in Linux

Those who really want to start learning a language will find it easier to start learning the language by setting up a REPL as fast as possible. This makes it easy to experiment with some simple expressions. This post will covers the installation of Clojure and an editor on Ubuntu Linux to set up a REPL.

Since Clojure runs on the Java Virtual Machine, one will need to install Java on your system. This, Here, is an easy way to do exactly that.

Now that Java is installed, one can install leiningen, a helpful tool for managing Clojure projects, especially when starting with Clojure.

To Install Leiningen:

Use Ubuntu’s package manager:

Or use wget:
wget puts files in your current working directory, which is home by default.

Installing a text editor:

Many people like using slime emacs for Clojure development, but for people who haven’t used emacs before I suggest using Nightcode. It is easier not to have to learn Clojure and a complex text-based editor like emacs at the same time. For this reason, Nightcode is a good alternative.

To install Nightcode download the .deb file and double click on it to open a window with the option to install it on your system.

Creating a New Leiningen Project:

In the terminal type:

Lastly, open the project in Nightcode. A “Hello World!” console application is already generated for you.