Matplotlib
[link]
18 flashcards · Programming Languages · by charlie42
In plt.plot, what's plt?
Plotting library part of the matplotlib package. It's usually imported as: import matplotlib.pyplot as plt Matplotlib package also contains other parts besides pyplot
How to plot two lines on the same plot?
Full example:
Why this won't work?
plt.show() removes plot from memory, it can't be saved after
How is matplotlib usually imported?
import matplotlib.pyplot as plt
Where in this code we would specify the width of the line?
In the plt.plot(x, y) line
Alternative to specifying chart properties separately
Shorthand notation:
What are the elements of the shorthand notation of the chart properties, in the right order?
Where to specify chart properties in shorthand notation?
In the plt.plot() function, right after the data:
How to format part of a line?
No direct way, but you can plot part of the values and then the rest:
If you want to change the size of the graph, which function you would provide it to?
plt.figure()
What is figure size measured in?
Inches
What can you do if resolution of your graph is low?
Change DPI
If you want to change the DPI of the graph, which function you would provide it to?
plt.figure() or plt.savefig()
What does plt.bar() return?
A list of bars You can assign properties to them like background (set_hatch)
Good DPI value
300
How to make neat bin values like this?
You need to specify tick values manually, equal to the bins
How to get hex value of any color?
Google "color picker"
How to make colors in your plot less ugly in one command?
plt.style.use('ggplot')