Skip to content

ENH: Add the ability to have a separate title for each subplot when plotting #14753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Dec 9, 2016
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions pandas/tools/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,11 @@ def _adorn_subplots(self):

if self.title:
if self.subplots:
self.fig.suptitle(self.title)
if type(self.title) == list:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls use is_list_like, and check the input length are correct. Note that all the axes may not require title when you specify layout

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I'll use is_list_like. I purposely did not check the lengths as a feature. As it's written, if you only provide a list of two strings, but the plot has 3 suplots, the first two subplots will have a title and the third will be left without one.

for (ax, title) in zip(self.axes, self.title):
ax.set_title(title)
else:
self.fig.suptitle(self.title)
else:
self.axes[0].set_title(self.title)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should raise if subplots=False and input is list-like


Expand Down Expand Up @@ -2555,8 +2559,12 @@ def _plot(data, x=None, y=None, subplots=False,
figsize : a tuple (width, height) in inches
use_index : boolean, default True
Use index as ticks for x axis
title : string
Title to use for the plot
title : string or list
If a string is passed, print the string at the top of the figure. If a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you leave the starting sentence "Title to use for the plot" ?

list of strings is passed and subplots is True, print the the first
string above the first subplot, the second string above the second
subplot, and so forth until the end of the list is reached or there are
no more subplots.
grid : boolean, default None (matlab style default)
Axis grid lines
legend : False/True/'reverse'
Expand Down