Practical solutions

Python Matplotlib Howto's How-To Guides

Solve the problem. Keep building. Collection of Python Matplotlib how-to articles

Find the answer you need

Browse practical solutions, grouped by the task you're working on.

__COUNT__ entries on this page

How to Set the Figure Title and Axes Labels Font Size in MatplotlibThe size and font of title and axes in Matplotlib can be set using font size parameter, label.set_size(), and rcParams dictionary. How to Plot a Circle in MatplotlibWe can plot a circle using patches circle, circle equation, and scatter plot in Matplotlib. How to Plot a 2D Heatmap With MatplotlibWe can plot a 2D heatmap using imshow() function,seaborn library and pcolormesh() function. How to Display Multiple Images in One Figure Correctly in MatplotlibWe can display multiple images in one figure in Matplotlib by using subplot in for loop to display every image. How to Manually Set the Size of the Bins in Matplotlib HistogramTo manually set the size of the bins in Matplotlib we calculate the number of bins for required width and pass no. of bins as a parameter in hist2d() function. How to Change Space Between Subplots in MatplotlibWe use tight_layout(), subplots_adjust() and subplot_tool() methods to change subplot size/space in Matplotlib. How to Connect Scatterplot Points With Line in MatplotlibWe can connect scatterplot points with a line by calling show() after we have called both scatter() and plot(), calling plot() with the line and point attributes, and using the keyword zorder. How to Add Title to Subplots in MatplotlibWe can add a title to subplots in matplotlib using set_title() and title.set_text() method. How to Hide Axis Text Ticks and/or Tick Labels in MatplotlibDifferent methods could hide axis text ticks and/or tick labels in Matplotlib like xaxis.set_visible(False), xaxis.set_ticks([]), xaxis.set_ticklabels([]), and setting the ticks color to be white. How to Draw Rectangle on Image in MatplotlibThis how-to article introduces how to draw rectangle on image in Matplotlib. Rectangle patch should be added to the plot by add_patch method to draw the rectangle on image in Matplotlib How to Create Different Subplot Sizes in MatplotlibThis how-to article introduces how to create different subplots size in Matplotlib. How to Place Legend Outside the Plot in MatplotlibThis tutorial introduces how to place legend outside the plot in Matplotlib. How to Set Tick Labels Font Size in MatplotlibThis tutorial introduces how to set tick labels font size in Matplotlib. How to Rotate X-Axis Tick Label Text in MatplotlibThis tutorial introduces how to rotate x-axis xtickslabel text in Matplotlib. How to Plot Horizontal and Vertical Line in MatplotlibThis tutorial introduces how to plot horizontal and vertical line in Matplotlib. We introduce two methods that use different coordinates in Matplotlib. %matplotlib NotebookThis post concentrates on explaining the different steps that are involved in creating a %matplotlib notebook graph in Python using the Matplotlib package. So, all detail about the %matplotlib notebook is available in this blog. Differences Between cla(), clf() and close() Methods in MatplotlibThis tutorial introduces the differences between methods: cla(), clf() and close(). matplotlib.pyplot.cla() method clears the current axes, matplotlib.pyplot.clf() method clears the current figure and matplotlib.pyplot.close() method closes the entire window. twinx and twiny in MatplotlibThis tutorial explains how we can create twin axes in Matplotlib with common X-axis or Y-axis using matplotlib.axes.Axes.twinx() and matplotlib.axes.Axes.twiny() in Python. Matplotlib.pyplot.specgram() in PythonThis tutorial explains how we can plot spectrograms in Python using the matplotlib.pyplot.specgram() and scipy.signal.spectrogram() methods. Matplotlib 3D ProjectionThis tutorial explains how we can create 3d plots using the Matplotlib using the mplot3d package from the mpl_toolkits library. Color Cycle in MatplotlibIn this demo tutorial, we introduce the color cycle and see how to get and set the color property with the help of the color cycle in Matplotlib. Matplotlib PyCharmIn this article, we will learn installing Matplotlib in PyCharm IDE. We are also visualizing the data in line, bar, histogram, grid, and marker plots. No Handles With Labels Found to Put in LegendThis article demonstrates how we can solve the warning (No handles with labels found to put in legend) when trying to plot something with Matplotlib. Magic Function Inline in MatplotlibIn this demonstration we learn what is magic function then we see different magic functions available in Matplotlib after this we discuss the inline function.