| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| Change return value of Axes.get_shared_[x,y,z]_axes() | ||
| ----------------------------------------------------- | ||
|
|
||
| The method `matplotlib.Axes.get_shared_x_axes` (and y and z) used to return `~.cbook.Grouper` objects. | ||
| Now it returns a `~.weakref.WeakSet` object. | ||
|
|
||
| Workarounds: | ||
| * If the intention is to get siblings as previous then the WeakSet contains all the siblings. | ||
| An example:: | ||
|
|
||
| sharedx = ax.get_shared_x_axes().get_siblings() | ||
| # is now | ||
| sharedx = list(ax.get_shared_x_axes()) | ||
|
|
||
| * If the intention was to use `join` then there is a new share axes method. An example:: | ||
|
|
||
| ax1.get_shared_x_axes().join(ax1, ax2) | ||
| # is now | ||
| ax1.share_x_axes(ax2) | ||
|
|
||
| * If the intention was to check if two elements are in the same group then use the `in` operator. An example:: | ||
|
|
||
| ax1.get_shared_x_axes().joined(ax1, ax2) | ||
| # is now | ||
| ax2 in ax1.get_shared_x_axes() | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| Remove share through `matplotlib.Axes.get_shared_{x,y,z}_axes` | ||
| -------------------------------------------------------------- | ||
|
|
||
| Previously when different axes are created with different parent/master axes, | ||
| the share would still be symmetric and transitive if an unconventional | ||
| method through `matplotlib.Axes.get_shared_x_axes` | ||
| is used to share the axes after creation. With the new sharing mechanism | ||
| this is no longer possible. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| Share and unshare `axes` after creation | ||
| --------------------------------------- | ||
|
|
||
| `matplotlib.axes.Axes` have `matplotlib.axes.Axes.unshare_x_axes`, | ||
| `matplotlib.axes.Axes.unshare_y_axes`, `matplotlib.axes.Axes.unshare_z_axes` | ||
| and `matplotlib.axes.Axes.unshare_axes` methods to unshare axes. | ||
| Similiar there are `matplotlib.axes.Axes.share_x_axes`, | ||
| `matplotlib.axes.Axes.share_y_axes`, `matplotlib.axes.Axes.share_z_axes` and | ||
| `matplotlib.axes.Axes.share_axes` methods to share axes. | ||
|
|
||
| Unshare an axis will decouple the viewlimits for further changes. | ||
| Share an axis will couple the viewlimits. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| """ | ||
| ============================================ | ||
| Parametric Curve with Share and Unshare Axes | ||
| ============================================ | ||
|
|
||
| This example demonstrates plotting a parametric curve in 3D, | ||
| and how to share and unshare 3D plot axes. | ||
| """ | ||
| import matplotlib as mpl | ||
| from mpl_toolkits.mplot3d import Axes3D | ||
| import numpy as np | ||
| import matplotlib.pyplot as plt | ||
|
|
||
| mpl.rcParams['legend.fontsize'] = 10 | ||
|
|
||
| # Prepare arrays x, y, z | ||
| theta = np.linspace(-4 * np.pi, 4 * np.pi, 100) | ||
| z = np.linspace(-2, 2, 100) | ||
| r = z ** 2 + 1 | ||
| x = r * np.sin(theta) | ||
| y = r * np.cos(theta) | ||
|
|
||
| fig = plt.figure() | ||
| ax = fig.add_subplot(311, projection='3d') | ||
|
|
||
| ax.plot(x, y, z, label='parametric curve') | ||
| ax.legend() | ||
|
|
||
| ax1 = fig.add_subplot(312) | ||
| ax1.plot(range(10)) | ||
| ax1.share_axes(ax) | ||
|
|
||
| ax2 = fig.add_subplot(313, projection='3d', sharex=ax) | ||
| ax2.plot(x, y, z) | ||
|
|
||
| ax2.unshare_x_axes() | ||
| ax2.share_z_axes(ax) | ||
|
|
||
| plt.show() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| """ | ||
| ====================== | ||
| Unshare and share axis | ||
| ====================== | ||
|
|
||
| The example shows how to share and unshare axes after they are created. | ||
| """ | ||
|
|
||
| import matplotlib.pyplot as plt | ||
| import numpy as np | ||
|
|
||
| t = np.arange(0.01, 5.0, 0.01) | ||
| s1 = np.sin(2 * np.pi * t) | ||
| s2 = np.exp(-t) | ||
| s3 = np.sin(4 * np.pi * t) | ||
|
|
||
| ax1 = plt.subplot(311) | ||
| plt.plot(t, s1) | ||
|
|
||
| ax2 = plt.subplot(312) | ||
| plt.plot(t, s2) | ||
|
|
||
| ax3 = plt.subplot(313) | ||
| plt.plot(t, s3) | ||
|
|
||
| ax1.share_x_axes(ax2) | ||
| ax1.share_y_axes(ax2) | ||
|
|
||
| # Share both axes. | ||
| ax3.share_axes(ax1) | ||
| plt.xlim(0.01, 5.0) | ||
|
|
||
| ax3.unshare_y_axes() | ||
| ax2.unshare_x_axes() | ||
|
|
||
| plt.show() | ||
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI didn't try to run this, but its hard to imagine this actually demos anything in a non-interactive session.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityYou do not create share as usual by setting a share parent axes. Sharing is set after the creation of the axes.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI think demos should be readily readable by users since they are one of the primary ways we document Matplotlib. I find this demo is very cryptic. Why are you un-sharing? Just to show that these functions exist? What effect does this have on the example? The description of the demo should state the usual way of sharing, and this alternate way.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualityhm... no comment.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.