Professional Documents
Culture Documents
Qbus5011 wk10 Vis
Qbus5011 wk10 Vis
Data Visualisation
1. Understanding (Week 9)
2. Assembling (Week 9)
3. Cleaning (Week 9)
4. Transforming (Week 10)
5. Sharing (Weeks 10 and 11)
Motivation
Motivation
1
https://www.aihw.gov.au/reports/eye-health/eye-health/
contents/how-common-is-visual-impairment
Visual Impairments - Colour Blindness
Accessibility - Rules of Thumb
The matplotlib library is expansive and allows for very low level
control over plotting elements.
2
https://matplotlib.org/stable/tutorials/introductory/pyplot.
html#intro-to-pyplot
3
https://realpython.com/python-matplotlib-guide/
#stateful-versus-stateless-approaches
Plotting in Ed
The first two parameters of functions like plot and scatter can be
of any array-like type. This means that Pandas Series objects can
be directly passed to these functions.
marketing = pd.read_csv('DirectMarketing.csv')
salary = marketing['Salary']
spent = marketing['AmountSpent']
plt.scatter(salary, spent)
Histograms
plt.hist(marketing['Salary'])
Bar Charts
xpos = [0, 1, 2, 3, 4, 5, 6, 7]
height = [507, 269, 123, 567, 245, 346, 429, 329]
plt.bar(xpos, height)
Mediums
Saving Figures
plt.savefig("plot.png")
With savefig the image file type is automatically inferred from the
extension in the filename.
Raster graphics
Most image formats that you encounter are raster graphics formats
e.g. JPEG, PNG and GIF. Video formats such as MP4 store the
image information in a raster format.
Common examples of vector file formats are PDF, SVG and EPS.
Vector Graphics
Vector Graphics
fig, ax = plt.subplots()
ln, = plt.plot([], [], 'r')
ax.set_xlim(-3, 3)
ax.set_ylim(-10.2, 10.2)
def update(i):
x = np.linspace(-3, 3)
y = i*np.sin(x+i*2)
ln.set_xdata(x)
ln.set_ydata(y)
LIVE DEMO
Too Many Guns
Too Many Guns
https://toomanyguns.herokuapp.com/
LIVE DEMO