Software tutorial/Creating and saving plots

From Process Model Formulation and Solution: 3E4
Jump to navigation Jump to search

Creating a plot

Plots in MATLAB and Python use an approach where you add successive elements to your graph. You start by plotting a line, then you may superimpose another line, optionally add some points, add a grid, title, labels and legend. Once completed, you can save your plot and add it to a document, website, or print it.

To introduce this section I will show how this plot, which we used in class, was created:

[[Media:

There are several libraries to create plots in Python, but one of the most well-developed and supported libraries is matplotlib; another reason to use this library is that its syntax is intentionally similar to MATLAB's.

Saving a plot

fig.savefig(FILENAME, dpi=300, facecolor='w', edgecolor='w', orientation='portrait', papertype=None, format=None, transparent=True)