DC Code Flashcards
What way do we use matplotlib?
Using the main object-oriented interface provided through the pyplot submodule.
How do we import the pyplot submodule?
import matplotlib.pyplot as plt
What does the plt.subplots() command do?
Creates two different objects - an axes and figure object.
What is the figure object?
A container which holds everything you see on the page.
What is the axes object?
The part of the page which holds the data.
What is the code to create an empty axes?
import matplotlib as plt
fig, ax = plt.subplots()
plt.show()
How do we add data to the axes?
ax.plot(data[“COL-1”], data[“COL-2”])
How do you add data to a figure?
Using the Axes object
What ways can you customise plots?
- Linestyle
- Point style (markers)
- Colours
- Add axes labels
- Add title label
Why are markers useful?
If a plot appears continuous, markers show us where the data exists and which parts are just lines connecting the data points.
How do you add a marker?
ax.plot(marker = “o”)
How do you edit the lifestyle?
ax.plot(linestyle=”–”)
How do you remove a line from the plot?
ax.plot(linestyle=”None”)
How do you edit the colour of the plotted data?
ax.plot(color=”r”)
How do you add axes labels?
ax.set_xlabel(“Text”)
ax.set_ylabel(“Text”)
What convention is used for capitalising the title?
Write it as you would a sentence - only first words and proper nouns are capitalised.