


You can use the following code to restore all fonts to their default size at any point: (plt.rcParamsDefault)
#Label scatter plot matplotlib how to
The following code shows how to change the font size of the tick labels of the plot: #set tick labels font to size 20 The following code shows how to change the font size of the axes labels of the plot: #set axes labels font to size 20Įxample 4: Change the Font Size of the Tick Labels Started toying around with the NFLScrapr package in python and am trying to create a scatter plot to display some info. The following code shows how to change the font size of the title of the plot: #set title font to size 50Įxample 3: Change the Font Size of the Axes Labels The following code shows how to change the font size of every element in the plot: #set font of all elements to size 15Įxample 2: Change the Font Size of the Title Example 1: Change the Font Size of All Elements plt.xlabel (fontweight’bold’) Read: Matplotlib subplot tutorial. plt.xlabel () method is used to create an x-axis label, with the fontweight parameter we turn the label bold. The next step is to define data and create graphs.

Note: The default font size for all elements is 10. We import the matplotlib.pyplot package in the example above. The following examples illustrates how to change the font sizes of various elements in the following matplotlib scatterplot: import matplotlib.pyplot as plt rc('legend', fontsize=10) #fontsize of the legend rc('ytick', labelsize=10) #fontsize of the y tick labels rc('xtick', labelsize=10) #fontsize of the x tick labels rc('axes', labelsize=10) #fontsize of the x and y labels rc('axes', titlesize=10) #fontsize of the title rc('font', size=10) #controls default text size Fortunately this is easy to do using the following code: import matplotlib.pyplot as plt the participant names as text labels for each point for xpos, ypos, label in zip(x, y, labels): ax.annotate(label. Often you may want to change the font sizes of various elements on a Matplotlib plot.
