8000 Improve custom figure example by timhoffm · Pull Request #14499 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Improve custom figure example #14499

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 1 commit into from
Jun 13, 2019

Conversation

timhoffm
Copy link
Member
@timhoffm timhoffm commented Jun 8, 2019

PR Summary

Just wanted to do a bit style cleanup, but ended up rewriting the whole example. 😄

I didn't like about the original example that it's not a reasonable application. Setting a fixed position Text as title is not quite suitable because it is not contained in any layout. If anything, one should use Figure.suptitle. But defining a subclass for this would be overkill. Using fig.suptitle('my title') explicitly is easier than plt.figure(FigureClass=MyFigure, title='my title').

@timhoffm timhoffm force-pushed the custom-figure-example branch from 9d8336e to b1c76db Compare June 8, 2019 18:53
@timhoffm timhoffm added this to the v3.2.0 milestone Jun 8, 2019

if watermark is not None:
bbox = dict(boxstyle='square', lw=3, ec='gray',
fc=(0.9, 0.9, .9, .5), alpha=0.5)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really care whether you use 0.9 or .9, but at least be consistent :) (and same with 0.5 here and below)

@@ -1,27 +1,55 @@
"""
===================
Custom Figure Class
Custom Figure class
Copy link
Contributor
@anntzer anntzer Jun 12, 2019

Choose a reason for hiding this comment

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

subclass? sure, in theory, it can be any class that's "figure-like", but in practice that'll be a Figure subclass.

Copy link
Member Author
@timhoffm timhoffm Jun 13, 2019

Choose a reason for hiding this comment

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

Maybe "Customizing Figure by subclassing" or just "Subclassing Figure"?

Copy link
Contributor

Choose a reason for hiding this comment

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

fine with me too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Any preference? The second one is shorter the first one is more precise.

Copy link
Contributor

Choose a reason for hiding this comment

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

"Custom Figure subclasses"?

===================

You can pass a custom Figure constructor to figure if you want to derive from
the default Figure. This simple example creates a figure with a figure title.
You can pass a custom Figure class to `.pyplot.figure` if you want to change
Copy link
Contributor

Choose a reason for hiding this comment

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

subclass?

Copy link
Contributor
@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

I like the new example a lot; only some tiny things, @timhoffm can self-merge after fixing them.

@timhoffm timhoffm force-pushed the custom-figure-example branch from b1c76db to 8ee355c Compare June 13, 2019 20:31
@anntzer anntzer merged commit e1f0101 into matplotlib:master Jun 13, 2019
@timhoffm timhoffm deleted the custom-figure-example branch June 13, 2019 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0