HassanK - 5 months ago 48

Python Question

I am trying to plot a simple 2 dimensional Bar Graph for two lists in python.

(note that max of this list is 4)

I want to plot this list and its corresponding index using Plotlib.

My code is this

`import numpy as np`

import matplotlib.pyplot as pl

bitpos = np.arange(len(sumlist))

pl.bar(bitpos,sumlist, align='center', alpha=0.5)

pl.ylabel('mismatch count')

pl.xlabel('bitposition')

The graph although plots correctly but the bars are touching the top of the graph (see the graph below) I want to create some empty space above the graph for a better presentation.

Example Plot to illustrate my problem

Answer

If you want to add some space to the top of your plot, you can add something like:

```
pl.ylim((0., 5.))
```

to the bottom of your current script.This changes the y limits of your plot to 0 and 5 (currently they are 0 and 4).