-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
artists.scatter
: plot unstructured data (#1050)
* working example * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * scatter_heatmap -> scatter * parse_limits, handle broadcasting * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * skip tests * cleanup tests * cleanup docs * changelog * refine scatter parameters, docstring * Update _base.py * ksunden comments random seed, correcting arg/kwarg parsing * Update _base.py scatter: replace full arrays with sufficiently full arrays * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * rst link Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Kyle Sunden <git@ksunden.space>
- Loading branch information
1 parent
e7e5459
commit 6d87f9d
Showing
4 changed files
with
143 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import numpy as np | ||
import WrightTools as wt | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
def test_scatter_broadcast_vars(): | ||
rng = np.random.default_rng(seed=42) | ||
data = wt.data.Data(name="data") | ||
a = rng.random((50, 1)) | ||
b = rng.random((1, 50)) | ||
data.create_variable("x", values=2 * a - 1) | ||
data.create_variable("y", values=2 * b - 1) | ||
data.create_channel("z", values=np.exp(-(data.x[:] ** 2 + data.y[:] ** 2))) | ||
fig, gs = wt.artists.create_figure() | ||
ax = plt.subplot(gs[0]) | ||
ax.scatter(data, x="x", y="y", channel="z", s=20, alpha=0.5) | ||
data.close() | ||
|
||
|
||
def test_scatter_signed_channel(): | ||
rng = np.random.default_rng(seed=42) | ||
data = wt.data.Data(name="data") | ||
a = rng.random((10**3)) | ||
b = rng.random((10**3)) | ||
data.create_variable("x", values=4 * np.pi * (a - 0.5)) | ||
data.create_variable("y", values=4 * np.pi * (b - 0.5)) | ||
data.create_channel("z", values=np.sin((data.x[:] ** 2 + data.y[:] ** 2) ** 0.5), signed=True) | ||
fig, gs = wt.artists.create_figure() | ||
ax = plt.subplot(gs[0]) | ||
ax.scatter(data, x="x", y="y", channel="z", s=20, alpha=0.5) | ||
data.close() | ||
|
||
|
||
if __name__ == "__main__": | ||
test_scatter_broadcast_vars() | ||
test_scatter_signed_channel() |