![]() Plt.show() indian = df='Indian']Īx.scatter(x=indian, y=indian, label='Indian', color='seagreen')Īx.scatter(x=overseas, y=overseas, label='overseas', color='crimson')Īx. Matplotlib ttext () Matplotlib plt.gca (). Plt.title("Runs vs Strike Rate", fontsize=20) Note to make the legends visible to also need to add the labels parameter in the scatter plot. To add legends in matplotlib, we use the plt.legend() or ax.legend(). However, the same method works with pyplot.subplots or keys that are different than what you want to label the subplot with. Note, here we use pyplot.subplotmosaic, and use the subplot labels as keys for the subplots, which is a nice convenience. ![]() fig, ax = plt.subplots(figsize=(10, 8))Īx.set_title('Runs vs Strike Rate', fontsize=20)Īx.set_xlabel('Strike Rate', fontsize=18) Simplest is putting the label inside the axes. You can see all the available methods for an axes instance in the api docs, here. Likewise, to set a title, you need ax.settitle. (Compare these to plt.xlabel, etc., for the state-machine interface). We can make them bigger using the fontsize parameter. When using the matplotlib object-oriented interface, the correct commands to use are ax.setxlabel and ax.setylabel. If you look at the figure above, you can see that axis labels as well as the title are very small. ![]() And to add y labels we use plt.ylabel() or ax.set_ylabel() plt.figure(figsize=(10, 8))Īdd x-axis and y-axis label in object oriented interface fig, ax = plt.subplots(figsize=(10, 8)) To add x axis labels, we use plt.xlabel() or ax.set_xlabel(). matplotlib matplotlib.afm matplotlib.animation. For more information read this post – Matlab Style interface vs Object oriented interface fig, ax = plt.subplots(figsize=(10, 8))Īx.scatter(x=df, y=df, color='seagreen') Plt.scatter(x=df, y=df, color='seagreen')Īx.set_title() is used for adding title to the object oriented interface plots. Now, let’s create a scatter plot and add a title to it. ![]() To add title in matplotlib, we use plt.title() or ax.set_title() In this post, you will learn how to add Titles, Axis Labels and Legends in your matplotlib plot. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |