-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
53 additions
and
122 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Use magicclass to plot\nrandom points and a histogram.""" | ||
import numpy as np | ||
import vedo | ||
try: | ||
from magicclass import magicclass, field | ||
from magicclass.ext.vtk import VedoCanvas | ||
except ImportError: | ||
print("Please install magicclass with: pip install magic-class") | ||
|
||
@magicclass | ||
class ViewerUI: | ||
canvas = field(VedoCanvas) | ||
|
||
def plot_random_points(self): | ||
"""Plot random data.""" | ||
# create a points object and a set of axes | ||
coords = np.random.randn(1000, 3) | ||
data = np.cos(coords[:,1]) | ||
points = vedo.Points(coords) | ||
points.cmap("viridis", data).add_scalarbar3d() | ||
axes = vedo.Axes(points, c="white") | ||
# create a histogram of data | ||
histo = vedo.pyplot.histogram( | ||
data, c="viridis", title=" ", xtitle="", ytitle="", | ||
) | ||
histo = histo.clone2d("bottom-right", size=0.25) | ||
ui.canvas.plotter.remove("Axes", "Points", "Histogram1D") | ||
ui.canvas.plotter.add(points, axes, histo) | ||
ui.canvas.plotter.reset_camera().render() | ||
|
||
if __name__ == "__main__": | ||
ui = ViewerUI() | ||
ui.canvas.plotter.add(__doc__) | ||
ui.show() |
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