Matplotlib Basic Plots Cheat Sheet

CleanlyDialect avatar
CleanlyDialect
·
·
Download

Start Quiz

Study Flashcards

6 Questions

What function is used to save a figure as a PDF in Matplotlib?

fig.savefig()

Which function is used to create a scatter plot in Matplotlib?

scatter()

In Matplotlib, what is the purpose of the 'imshow()' function?

Displaying an image

Which function in Matplotlib is specifically used for creating a legend?

plot()

What does the 'pcolormesh()' function do in Matplotlib?

Create pseudocolor plots

Which function in Matplotlib would you use to plot directional fields?

quiver()

Study Notes

###/matplotlib Basics/

  • plot() function is used to create a plot, taking in X, Y, and optional fmt, color, marker, and linestyle arguments.

Plotting Functions/

  • scatter() function creates a scatter plot, taking in X, Y, and optional sizes, colors, and marker arguments.
  • imshow() function displays an image, taking in Z, cmap, interpolation, extent, and origin arguments.
  • contour() and contourf() functions create contour plots, taking in X, Y, Z, levels, colors, extent, and origin arguments.
  • pcolormesh() function creates a pseudo-color plot, taking in X, Y, Z, vmin, vmax, and cmap arguments.

Figure Anatomy/

  • A figure in matplotlib consists of a title, projections, and a grid.

Projections/

  • Projections can be set using the '3d' argument, e.g. p='3d'.

Markers and Lines/

  • Markers can be customized in scatter plots using various symbols and styles.
  • Lines can be customized using various linestyles and formats.

Legends and Axes/

  • Legends can be created using the pie() function, taking in X, explode, labels, colors, and radius arguments.
  • Axis labels can be customized using the ticker module.

Subplots and Layout/

  • Subplots can be created using the subplot() or subplots() functions, taking in rows, cols, and other arguments.
  • Gridspec can be used to create complex layouts.
  • Axes can be added or removed using various methods.

Additional Functions/

  • fig.savefig() function saves a figure to a file.
  • plt.show() function displays a figure.
  • quiver() function creates a quiver plot, taking in X, Y, U, V, and other arguments.
  • step() function creates a step plot, taking in X, Y, and other arguments.
  • boxplot() function creates a box plot, taking in X, notch, sym, bootstrap, and widths arguments.
  • errorbar() function creates an error bar plot, taking in X, Y, xerr, yerr, and other arguments.

Learn about basic plots in Matplotlib, including scatter plots, imshow, contourf, and pcolormesh. Explore various parameters such as colors, markers, sizes, and color maps for different plot types.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Use Quizgecko on...
Browser
Browser