Data Visualization with Python Week 1
Artist Layer main objects
Composed of one main object-Artist
FigureCanvas
Defines and encompasses the area onto which the figure is drawn
Composite Artist object
Examples are Axis, Tick, Axes, and Figure
Primitive Artist object
Examples are Line2D, Rectangle, Circle, and Text
The three built-in interface classes of the Backend Layer
FigureCanvas, Renderer, Event
Event
Handles user inputs such as keystrokes and mouse clicks
Renderer
Knows how to draw on the FigureCanvas
Types of Artist objects
Primitive Composite
Matplotlib Architecture
Scripting Layer (pyplot) Artist Layer (Artist) Backend Layer (FigureCanvas, Renderer, Event)
Examples that correspond to individual Artist instances
Title, lines, tick labels, and images
Use the artist layer to create a stacked area plot of the data in the pandas dataframe, area_df.
ax = area_df.plot(kind='area', figsize=(20, 10)) ax.set_title('Plot Title') ax.set_ylabel('Vertical Axis Label') ax.set_xlabel('Horizontal Axis Label')
Create a histogram of a pandas series, series_data, and align the bin edges with the horizontal tick marks.
count, bin_edges = np.histogram(series_data) series_data.plot(kind='hist', xticks = bin_edges)
Create a stacked area plot of the data in the pandas dataframe, area_df, with a transparency value of 0.35
import matplotlib.pyplot as plt transparency = 0.35 area_df.plot(kind='area', alpha=transparency, figsize=(20, 10)) plt.title('Plot Title') plt.ylabel('Vertical Axis Label') plt.xlabel('Horizontal Axis Label') plt.show()
Code to use Event
matplotlib.backend_bases.Event
Code to use FigureCanvas
matplotlib.backend_bases.FigureCanvas
Code to use Renderer
matplotlib.backend_bases.Renderer
Given a pandas dataframe, question, create a horizontal bar chart of the data in question
question.plot(kind='barh')
By default area plots are
stacked