Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to add subtitle matplotlib

import pandas as pd
import matplotlib.pyplot as plt

d = {'series a' : pd.Series([1., 2., 3.], index=['a', 'b', 'c']),
      'series b' : pd.Series([1., 2., 3., 4.], index=['a', 'b', 'c', 'd'])}
df = pd.DataFrame(d)

title_string = "This is the title"
subtitle_string = "This is the subtitle"

plt.figure()
df.plot(kind='bar')
plt.suptitle(title_string, y=1.05, fontsize=18)
plt.title(subtitle_string, fontsize=10)
Comment

how to add subtitle to plot in python

import matplotlib.pyplot as plt
import numpy as np

# Simple data to display in various forms
x = np.linspace(0, 2 * np.pi, 400)
y = np.sin(x ** 2)

fig, axarr = plt.subplots(2, 2)
fig.suptitle("This Main Title is Nicely Formatted", fontsize=16)

axarr[0, 0].plot(x, y)
axarr[0, 0].set_title('Axis [0,0] Subtitle')
axarr[0, 1].scatter(x, y)
axarr[0, 1].set_title('Axis [0,1] Subtitle')
axarr[1, 0].plot(x, y ** 2)
axarr[1, 0].set_title('Axis [1,0] Subtitle')
axarr[1, 1].scatter(x, y ** 2)
axarr[1, 1].set_title('Axis [1,1] Subtitle')

# Fine-tune figure;
# hide x ticks for top plots and y ticks for right plots

plt.setp([a.get_xticklabels() for a in axarr[0, :]], visible=False)
plt.setp([a.get_yticklabels() for a in axarr[:, 1]], visible=False)


# Tight layout often produces nice results
# but requires the title to be spaced accordingly

fig.tight_layout()
fig.subplots_adjust(top=0.88)

plt.show()


Comment

PREVIOUS NEXT
Code Example
Python :: get binary string python 
Python :: savefig matplotlib python 
Python :: colon in array python 
Python :: log log grid python 
Python :: create a window using tkinter 
Python :: matplotlib remove duplicate legend entries from plotting loop 
Python :: python os.walk recursive 
Python :: read pickle file 
Python :: autopytoexe 
Python :: convert datetime to date pandas 
Python :: slicing in python 
Python :: spyder new instance 
Python :: reverse array python 
Python :: pygame examples 
Python :: pandas filter dataframe if an elemnt is in alist 
Python :: pandas dataframe for loop begin end index 
Python :: convert .py to exe 
Python :: tkinter maximise window 
Python :: python script to convert dicom to niftii 
Python :: Code to implement iterative Binary Search 
Python :: python multiply 2 variables 
Python :: how to go to previous directory in os python 
Python :: merge two columns name in one header pandas 
Python :: Error: getaddrinfo ENOTFOUND www.python.org www.python.org:443 Downloading Python failed. Error: { Error: getaddrinfo ENOTFOUND www.python.org www.python.org:443 
Python :: open file with python 
Python :: Python List count() example 
Python :: pickling python example 
Python :: Add Cog to bot in Discord.py 
Python :: imagefield django models 
Python :: python merge list of dict into single dict 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =