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 matplotlib

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 :: pause program python 
Python :: python tkinter lable on bottom of screen 
Python :: ignore error open file python 
Python :: reverse one hot encoding python numpy 
Python :: pandas get numeric columns 
Python :: grid search python 
Python :: selenium iframe python 
Python :: how to take password using pyautogui 
Python :: how to traverse a linked list in python 
Python :: python volver al principio 
Python :: typingclub hack python 
Python :: how to use an indefinite number of args in python 
Python :: matplotlib set y lim 
Python :: fig title python 
Python :: pandas datetime to date 
Python :: enumurate in python 
Python :: cartesian product of a list python 
Python :: ANSHUL 
Python :: knn plot the clusters 
Python :: dataframe how to substruct 2 dates 
Python :: python sort file names with numbers 
Python :: how to fill an array with consecutive numbers python 
Python :: python min length list of strings 
Python :: binning data dataframe, faire classe statistique dataframe 
Python :: pandas dataframe select rows not in list 
Python :: split imagedatagenerator into x_train and y_train 
Python :: não nulo pandas 
Python :: python tipi array 
Python :: count number of rows pandas condition 
Python :: pandas plot heatmap 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =