Create a duplicate of the dictionary for the default colorbar parameters of plot2D
#2380
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The colorbar feature for
plot2D
added in #2289 produces an error when trying to add colorbars to more than one subplots of a singlematplotlib.figure
object. This is because the dictionary of default parameters for the colorbar (default_colorbar_parametrs
ofvisualization.py
) is passed by reference and the use ofpop
to retrieve its parameters when adding the colorbar to the first subplot removes them from the dictionary. Subsequent calls to retrieve the same parameters in turn triggers an error. The fix involves simply creating a duplicate of the dictionary.Here is an example which demonstrates this bug:
Executing this script using the current master branch triggers an error related to a missing
pad
key entry in the dictionary when trying to add a colorbar to the second subplot:With the fix in this PR, colorbars are correctly added to both subplots as shown in the following image:
cc @thomasdorch