TODO: migrate into a blog article for reusability
The pyplot
interface for Matplotlib is more of a helping tool for users who are already adept in plotting with MATLAB and would like to transition to Python-based tooling with minimal friction. The plotting commands are declarative: you call plot(x_arr, y_arr)
to generate the plot, xlim(x_min, y_min)
to set the x-axis limits, and savefig("filename.png")
to generate the file. Like MATLAB, a GUI pops up when you call the plot
function where you can manipulate and save the figure. The approach puts a strong emphasis to exploratory analysis and quick prototyping, at the cost of having the plotting defaults making your figures look dull.
Thought list:
subplots
to generate both the figure and axis objects: it already makes it easy to add multiple axes within the figure, and allows you to resize it right within the generator.ax.set_<property>
is sufficient, but a cleaner approach would be to use ax.set(**style_dict)
.Examples: (Note: might be a separate post, mostly boilerplates or design patterns)