Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
CreateInsetIndicator
artist#27996
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
******************** | ||
``matplotlib.inset`` | ||
******************** | ||
.. automodule:: matplotlib.inset | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
``InsetIndicator`` artist | ||
~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
`~.Axes.indicate_inset` and `~.Axes.indicate_inset_zoom` now return an instance | ||
of `~matplotlib.inset.InsetIndicator`. Use the | ||
`~matplotlib.inset.InsetIndicator.rectangle` and | ||
`~matplotlib.inset.InsetIndicator.connectors` properties of this artist to | ||
access the objects that were previously returned directly. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
``InsetIndicator`` artist | ||
~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
`~.Axes.indicate_inset` and `~.Axes.indicate_inset_zoom` now return an instance | ||
of `~matplotlib.inset.InsetIndicator` which contains the rectangle and | ||
connector patches. These patches now update automatically so that | ||
.. code-block:: python | ||
ax.indicate_inset_zoom(ax_inset) | ||
ax_inset.set_xlim(new_lim) | ||
now gives the same result as | ||
.. code-block:: python | ||
ax_inset.set_xlim(new_lim) | ||
ax.indicate_inset_zoom(ax_inset) |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -16,6 +16,7 @@ | ||||||||||||||
import matplotlib.contour as mcontour | ||||||||||||||
import matplotlib.dates # noqa: F401, Register date unit converter as side effect. | ||||||||||||||
import matplotlib.image as mimage | ||||||||||||||
import matplotlib.inset as minset | ||||||||||||||
import matplotlib.legend as mlegend | ||||||||||||||
import matplotlib.lines as mlines | ||||||||||||||
import matplotlib.markers as mmarkers | ||||||||||||||
@@ -419,9 +420,9 @@ def inset_axes(self, bounds, *, transform=None, zorder=5, **kwargs): | ||||||||||||||
return inset_ax | ||||||||||||||
@_docstring.interpd | ||||||||||||||
def indicate_inset(self, bounds=None, inset_ax=None, *, transform=None, | ||||||||||||||
facecolor='none', edgecolor='0.5', alpha=0.5, | ||||||||||||||
zorder=None, **kwargs): | ||||||||||||||
""" | ||||||||||||||
Add an inset indicator to the Axes. This is a rectangle on the plot | ||||||||||||||
at the position indicated by *bounds* that optionally has lines that | ||||||||||||||
@@ -433,18 +434,19 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None, | ||||||||||||||
Parameters | ||||||||||||||
---------- | ||||||||||||||
bounds : [x0, y0, width, height], optional | ||||||||||||||
Lower-left corner of rectangle to be marked, and its width | ||||||||||||||
and height. If not set, the bounds will be calculated from the | ||||||||||||||
data limits of *inset_ax*, which must be supplied. | ||||||||||||||
inset_ax : `.Axes`, optional | ||||||||||||||
An optional inset Axes to draw connecting lines to. Two lines are | ||||||||||||||
drawn connecting the indicator box to the inset Axes on corners | ||||||||||||||
chosen so as to not overlap with the indicator box. | ||||||||||||||
transform : `.Transform` | ||||||||||||||
Transform for the rectangle coordinates. Defaults to | ||||||||||||||
``ax.transAxes``, i.e. the units of *rect* are in Axes-relative | ||||||||||||||
coordinates. | ||||||||||||||
facecolor : :mpltype:`color`, default: 'none' | ||||||||||||||
@@ -469,15 +471,20 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None, | ||||||||||||||
Returns | ||||||||||||||
------- | ||||||||||||||
inset_indicator : `.inset.InsetIndicator` | ||||||||||||||
An artist which contains | ||||||||||||||
inset_indicator.rectangle : `.Rectangle` | ||||||||||||||
The indicator frame. | ||||||||||||||
inset_indicator.connectors : 4-tuple of `.patches.ConnectionPatch` | ||||||||||||||
The four connector lines connecting to (lower_left, upper_left, | ||||||||||||||
lower_right upper_right) corners of *inset_ax*. Two lines are | ||||||||||||||
set with visibility to *False*, but the user can set the | ||||||||||||||
visibility to True if the automatic choice is not deemed correct. | ||||||||||||||
Comment on lines +477 to +485 Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. would it make sense to make this an interpolated doc, even if it's only used in like two places? That way it can be defined in the module? Only thinking about this b/c of how it's being done for colorizer: matplotlib/lib/matplotlib/colorizer.py Lines 29 to 34 incf9a943
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Possibly can do something even more direct but I do not follow this example at allhttps://matplotlib.org/devdocs/devel/document.html#keyword-arguments There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Do we have any general guidance about when it makes sense to do this rather than copy/paste? As you say it's only in two places and I am keenly aware that I have a lot more copy/paste going on in the artist's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. | ||||||||||||||
.. versionchanged:: 3.10 | ||||||||||||||
Previously the rectangle and connectors tuple were returned. | ||||||||||||||
""" | ||||||||||||||
# to make the Axes connectors work, we need to apply the aspect to | ||||||||||||||
# the parent Axes. | ||||||||||||||
@@ -487,51 +494,13 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None, | ||||||||||||||
transform = self.transData | ||||||||||||||
kwargs.setdefault('label', '_indicate_inset') | ||||||||||||||
indicator_patch = minset.InsetIndicator( | ||||||||||||||
bounds, inset_ax=inset_ax, | ||||||||||||||
facecolor=facecolor, edgecolor=edgecolor, alpha=alpha, | ||||||||||||||
zorder=zorder, transform=transform, **kwargs) | ||||||||||||||
self.add_artist(indicator_patch) | ||||||||||||||
return indicator_patch | ||||||||||||||
def indicate_inset_zoom(self, inset_ax, **kwargs): | ||||||||||||||
""" | ||||||||||||||
@@ -555,22 +524,23 @@ def indicate_inset_zoom(self, inset_ax, **kwargs): | ||||||||||||||
Returns | ||||||||||||||
------- | ||||||||||||||
inset_indicator : `.inset.InsetIndicator` | ||||||||||||||
An artist which contains | ||||||||||||||
inset_indicator.rectangle : `.Rectangle` | ||||||||||||||
The indicator frame. | ||||||||||||||
inset_indicator.connectors : 4-tuple of `.patches.ConnectionPatch` | ||||||||||||||
The four connector lines connecting to (lower_left, upper_left, | ||||||||||||||
lower_right upper_right) corners of *inset_ax*. Two lines are | ||||||||||||||
set with visibility to *False*, but the user can set the | ||||||||||||||
visibility to True if the automatic choice is not deemed correct. | ||||||||||||||
.. versionchanged:: 3.10 | ||||||||||||||
Previously the rectangle and connectors tuple were returned. | ||||||||||||||
""" | ||||||||||||||
return self.indicate_inset(None, inset_ax, **kwargs) | ||||||||||||||
@_docstring.interpd | ||||||||||||||
def secondary_xaxis(self, location, functions=None, *, transform=None, **kwargs): | ||||||||||||||
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.