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
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.
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.
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.
Set_title() Method to Add Title to Subplot in Matplotlib. title. set_text() Method to Set Title of Subplots in Matplotlib. plt.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With