savefig does not issue a warning on a non-existent keyword name
Example
Savefig('filename.png', NonExistant=True)
Will not throw any warning. This is especially important if you accidentally misspell an argument, such as:
Savefig('filename.png', tranperent=True)
Notice 'transperent' instead of 'transparent'
@ootz0rz: I've had a quick look at your attached commit. I think probably the best approach to resolving this issue would be to go through the backend_*.py files, looking for the cases where **kwargs have been accepted, but not used. For instance, if you remove the **kwargs in backends_agg.py's print_png function, then you might find that Python does the error handling for you for "pngs" at least.
Do you fancy getting involved and seeing how you get on implementing a fix?
Started to look into this again, it is a rat's nest.
print_figure throws the kitchen sink at the underlying print functions so if we want to lock this down we need to lock down the union of the keywords expected in all of the print functions.
Unfortunately, there's some incomplete implementations of some keyword arguments in some backends that makes this a bit more difficult than it should be.
Activity
quick patch for issue matplotlib#192
pelson commented on Jun 18, 2012
@ootz0rz: I've had a quick look at your attached commit. I think probably the best approach to resolving this issue would be to go through the backend_*.py files, looking for the cases where **kwargs have been accepted, but not used. For instance, if you remove the **kwargs in backends_agg.py's print_png function, then you might find that Python does the error handling for you for "pngs" at least.
Do you fancy getting involved and seeing how you get on implementing a fix?
tacaswell commented on Feb 16, 2016
Started to look into this again, it is a rat's nest.
print_figure throws the kitchen sink at the underlying print functions so if we want to lock this down we need to lock down the union of the keywords expected in all of the print functions.
anntzer commented on Apr 22, 2020
fwiw mplcairo simply lists the (extra) allowed kwargs in mplcairo.base._check_print_extra_kwargs, and throws if anything not in there is passed.
QuLogic commented on Apr 22, 2020
Unfortunately, there's some incomplete implementations of some keyword arguments in some backends that makes this a bit more difficult than it should be.
Warn on invalid savefig keyword arguments.
Warn on invalid savefig keyword arguments.
Warn on invalid savefig keyword arguments.
Warn on invalid savefig keyword arguments.
Warn on invalid savefig keyword arguments.