Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Figure Title set at Bottom

I am using Matplotlib and want to show my title at the bottom below my labels. Below is the code I am trying.

plt.scatter(ax1['favorite_count'], ax1['citation_count'], c="DarkBlue", alpha=0.5)
plt.text(15, 15,"Correlation Graph between Citation & Favorite Count")
plt.show()

But I show at the right of the graph above the x-axis. Anyone here to guide me how to do this

like image 575
Asma Ahmad Avatar asked Sep 16 '18 05:09

Asma Ahmad


People also ask

How do I change the position of a title in Matplotlib?

Matplotlib can display plot titles centered, flush with the left side of a set of axes, and flush with the right side of a set of axes. Automatic positioning can be turned off by manually specifying the y keyword argument for the title or setting rcParams["axes.

How do you put a title under a plot in Python?

MatPlotLib with Python Set the figure size and adjust the padding between and around the subplots. Initialize a variable, N, to get the number of sample data. Plot the x and y data points using scatter() method. Set the title at the bottom of the figure in matplotlib, with y=-0.01.

How do you increase distance between title and plot in Python?

MatPlotLib with Python Create point x using numpy. Create point y using numpy sin. Set the title of the plot. After changing the value y (in argument), we can increase or decrease the distance between the title and the plot.

Which method is used to add title to the subplots using Matplotlib?

Set_title() Method to Add Title to Subplot in Matplotlib. title. set_text() Method to Set Title of Subplots in Matplotlib. plt.


1 Answers

If you are trying to set text() method there are x and y coordinates you can use to change the location of the text. Using any negative value would place it below the axis. Make sure that all your texts and titles are placed properly and do not overlap each other.

import matplotlib.pyplot as plt

plt.text(15, -0.01, "Correlation Graph between Citation & Favorite Count")

Same for a title:

import matplotlib.pyplot as plt

plt.title('Scatter plot pythonspot.com', y=-0.01)

Here is more info about the matplotlib text() and title() methods

like image 56
Alex Avatar answered Oct 21 '22 18:10

Alex