Refactor legend+colorbar internals, support "queueing" and location-based replacements #254
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.
Resolves #198. Proplot supports more than one legend per subplot. However this means that each
legend()
call creates a brand new legend -- sometimes one on top of another. This was confusing to new users (IIRC there's a closed issue floating around) and broke external packages that rely on one legend per subplot (#198).This PR does the best of both worlds. Proplot still supports multiple legends, but not on top of each other. If you call
legend()
more than once with the same locationloc
(or withoutloc
, implying the same default location), proplotwill either 1) replace the previous legend (if
queue=False
, the default) or 2) add handles to a "queue" (ifqueue=True
). This "queueing" option was previously only available in the wrapper functions, which didn't make sense.This PR also cleans up/organizes the messy legend and colorbar code. It also changes behavior:
legend(..., center=True)
no longer returns the background patch. I think it's kind of weird forlegend()
to return a non-legend object and "inner colorbars" made with e.g.colorbar(..., loc='upper right')
also don't return the patch. Really should just merge #74.Here's the example from #198 (no more errors):
Here's an example showing the new location-specific legend-replacing behavior:
And here's an example of the now publicly-available
queue
feature: