Apache Log Visualization with Matplotlib : Learn Data Science

This post discusses Apache log visualization with Matplotlib library.
First, download the data file used in this example from here.

We will require numpy and matplotlib

In [1]:
import numpy as np
import matplotlib.pyplot as plt

numpy.loadtext() can directly load a text file in an array
requests-idevji.txt contains only hour on which request was made, this is achieved by pre-prcoessing the Apache log.

In [2]:
data = np.loadtxt ('requests-idevji.txt')

We need 24 bins because we have 24 hours’ data. For other attributes of hist() see references.

In [3]:
plt.hist(data, bins=24)
plt.title("Requests @ iDevji")
plt.ylabel("# Requests")
Text(0,0.5,'# Requests')
In [4]:


  1. numpy.loadtext(), Scipy.org
  2. PyPlot API, Matplotlib.org

1 comment

Leave a comment

Your email address will not be published. Required fields are marked *