Matplotlib

[link]

18 flashcards · Programming Languages · by charlie42

  1. 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

  2. How to plot two lines on the same plot?

    Full example:

  3. Why this won't work?

    plt.show() removes plot from memory, it can't be saved after

  4. How is matplotlib usually imported?

    import matplotlib.pyplot as plt

  5. Where in this code we would specify the width of the line?

    In the plt.plot(x, y) line

  6. Alternative to specifying chart properties separately

    Shorthand notation:

  7. What are the elements of the shorthand notation of the chart properties, in the right order?

  8. Where to specify chart properties in shorthand notation?

    In the plt.plot() function, right after the data:

  9. How to format part of a line?

    No direct way, but you can plot part of the values and then the rest:

  10. If you want to change the size of the graph, which function you would provide it to?

    plt.figure()

  11. What is figure size measured in?

    Inches

  12. What can you do if resolution of your graph is low?

    Change DPI

  13. If you want to change the DPI of the graph, which function you would provide it to?

    plt.figure() or plt.savefig()

  14. What does plt.bar() return?

    A list of bars You can assign properties to them like background (set_hatch)

  15. Good DPI value

    300

  16. How to make neat bin values like this?

    You need to specify tick values manually, equal to the bins

  17. How to get hex value of any color?

    Google "color picker"

  18. How to make colors in your plot less ugly in one command?

    plt.style.use('ggplot')