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 :: matplotlib plot 
Python :: upgrade python to 3.9 i linux 
Python :: pandas show complete string 
Python :: python program for geometric progression 
Python :: sns scatter plot 
Python :: change name of column pandas 
Python :: bubble sort python 
Python :: python init matrix 
Python :: uninstall python from mac 
Python :: python make a shop menu 
Python :: divide by zero errors when using annotate 
Python :: truncate date to midnight in pandas column 
Python :: pandas filter and change value 
Python :: media url django 
Python :: python dump object print 
Python :: python nested tqdm 
Python :: how to run a .exe through python 
Python :: pandas percentage change across 3 periods 
Python :: python seaborn violin plot fit data better 
Python :: create a sequence of numbers in python 
Python :: copy a 2d array in python 
Python :: how to fill an array with consecutive numbers 
Python :: access element of dataframe python 
Python :: binning dat adataframe 
Python :: pair plot python 
Python :: ursina code 
Python :: serializers.py include all fields 
Python :: install pyaudio linux 
Python :: how to set the size of a gui in python 
Python :: seasonal_decompose python 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =