Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

add caption to plot python

txt="I need the caption to be present a little below X-axis"
plt.figtext(0.5, 0.01, txt, wrap=True, horizontalalignment='center', fontsize=12)
Comment

add caption to plot python


from matplotlib import pyplot as plt
import numpy as np

txt="I need the caption to be present a little below X-axis"

# make some synthetic data
x = np.linspace(0, 1, 512)
y = np.random.rand(512)*2.3 + .1

fig = plt.figure()
ax1 = fig.add_axes((0.1, 0.2, 0.8, 0.7))

ax1.set_title("This is my title")
ax1.set_xlabel('X-axis')
ax1.set_ylabel('Y-axis')

# make the edge colors match the facecolors
ax1.scatter(x,y, c='r', edgecolors='face')
# center text
fig.text(.5, .05, txt, ha='center')

# use OO interface    
ax1.set_xlim([0, 1.05])
ax1.set_ylim([0, 2.5])

# resize the figure to match the aspect ratio of the Axes    
fig.set_size_inches(7, 8, forward=True)

plt.show()

Comment

PREVIOUS NEXT
Code Example
Python :: How to round to 2 decimals with Python? 
Python :: showing specific columns pandas 
Python :: django now template tag 
Python :: breadth first search python 
Python :: python open file for reading and writing 
Python :: python input code 
Python :: userregisterform 
Python :: Calculate Euclidean Distance in Python 
Python :: python rgb to hex 
Python :: spotipy currently playing 
Python :: Splitting training and test data using sklearn 
Python :: pandas remove leading trailing spaces in dataframe 
Python :: pandas save dataframe to csv in python 
Python :: euclidean distance python 3 variables 
Python :: bucketizer pyspark 
Python :: python 3d array 
Python :: python turtle triangle 
Python :: Convert two lists into a dictionary in python 
Python :: create a dataframe from dict 
Python :: how to change frame in tkinter 
Python :: d-tale colab 
Python :: matplotlib subplots 
Python :: python find digits in string 
Python :: subtract number from each element in list python 
Python :: python json web request 
Python :: copy files to a directory using text file 
Python :: how to read panda column 
Python :: python int to string 
Python :: creating a sqlite3 table in python and inserting data in it 
Python :: notna pandas 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =