-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Conversation
9d8336e
to
b1c76db
Compare
|
||
if watermark is not None: | ||
bbox = dict(boxstyle='square', lw=3, ec='gray', | ||
fc=(0.9, 0.9, .9, .5), alpha=0.5) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine with me too.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subclass?
There was a problem hiding this 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.
b1c76db
to
8ee355c
Compare
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 useFigure.suptitle
. But defining a subclass for this would be overkill. Usingfig.suptitle('my title')
explicitly is easier thanplt.figure(FigureClass=MyFigure, title='my title')
.