-
Notifications
You must be signed in to change notification settings - Fork 268
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
39 changed files
with
1,164 additions
and
341 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
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,10 @@ | ||
from vtkplotter import donutPlot | ||
|
||
title = "A donut plot" | ||
fractions = [0.1, 0.2, 0.3, 0.1, 0.3] | ||
colors = [ 1, 2, 3, 4, 'white'] | ||
labels = ["stuff1", "stuff2", "compA", "compB", ""] | ||
|
||
dn = donutPlot(fractions, c=colors, labels=labels, title=title) | ||
|
||
dn.show(axes=None, bg='w') |
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 |
---|---|---|
@@ -1,26 +1,22 @@ | ||
""" | ||
Example for function() method. | ||
Draw a surface representing the 3D function specified as a string | ||
or as a reference to an external already existing function. | ||
Draw a surface representing a 2-var function specified | ||
as a string or as a reference to an external existing function. | ||
Red points indicate where the function does not exist. | ||
""" | ||
print(__doc__) | ||
from vtkplotter import Plotter, fxy, sin, cos, show | ||
from vtkplotter import fxy, sin, cos, show | ||
|
||
|
||
def my_z(x, y): | ||
return sin(2 * x * y) * cos(3 * y) / 2 | ||
|
||
|
||
# draw at renderer nr.0 the first actor, show it with a texture | ||
# an existing function z(x,y) can be passed: | ||
f1 = fxy(my_z) | ||
|
||
# red dots are shown where the function does not exist (y>x): | ||
# if vp is set to verbose, sympy calculates derivatives and prints them: | ||
f2 = fxy("sin(3*x)*log(x-y)/3") | ||
|
||
# specify x and y ranges and z vertical limits: | ||
f3 = fxy("log(x**2+y**2 - 1)", x=[-2, 2], y=[-2, 2], zlimits=[-1, 1.5]) | ||
f3 = fxy("log(x**2+y**2-1)", x=[-2,2], y=[-1,8], zlimits=[-1,None]) | ||
|
||
show(f1, f2, f3, N=3, axes=1, sharecam=False, bg="w") |
This file was deleted.
Oops, something went wrong.
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,25 @@ | ||
"""2D histogram with hexagonal binning.""" | ||
from vtkplotter import * | ||
import numpy as np | ||
|
||
N = 2000 | ||
x = np.random.randn(N) * 1.0 | ||
y = np.random.randn(N) * 1.5 | ||
|
||
# hexagonal histogram | ||
histo = hexHistogram(x, y, bins=10, fill=True, cmap='terrain') | ||
|
||
# scatter plot: | ||
pts = Points([x, y, np.zeros(N)+6], c="black", alpha=0.05) | ||
|
||
f = r'f(x, y)=A \exp \left(-\left(\frac{\left(x-x_{o}\right)^{2}}' | ||
f+= r'{2 \sigma_{x}^{2}}+\frac{\left(y-y_{o}\right)^{2}}' | ||
f+= r'{2 \sigma_{y}^{2}}\right)\right)' | ||
formula = Latex(f, c='k', s=1.5).rotateZ(90).rotateX(90).pos(1,-1,1) | ||
|
||
#settings.useParallelProjection = True | ||
settings.xtitle = "x gaussian, s=1.0" | ||
settings.ytitle = "y gaussian, s=1.5" | ||
settings.ztitle = "dN/dx/dy" | ||
|
||
show(histo, pts, formula, Text(__doc__), axes=1, verbose=0, bg="white") |
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,41 @@ | ||
from vtkplotter import polarHistogram, Hyperboloid, show | ||
import numpy as np | ||
np.random.seed(3) | ||
|
||
|
||
################################################################## | ||
radhisto = polarHistogram(np.random.rand(200)*6.28, | ||
title="random orientations", | ||
bins=10, | ||
#c='orange', #uniform color | ||
labels=["label"+str(i) for i in range(10)], | ||
) | ||
|
||
show(radhisto, at=0, N=2, axes=0, sharecam=False, bg="white") | ||
|
||
|
||
################################################################## | ||
hyp = Hyperboloid(res=20).cutWithPlane().rotateY(-90) | ||
hyp.color('grey').alpha(0.3) | ||
|
||
# select 10 random indeces of points on the surface | ||
idx = np.random.randint(0, hyp.NPoints(), size=10) | ||
|
||
radhistos = [] | ||
for i in idx: | ||
#generate a random histogram | ||
rh = polarHistogram(np.random.randn(100), | ||
bins=12, | ||
r1=0.2, # inner radius | ||
phigap=1.0, # leave a space btw phi bars | ||
cmap='viridis_r', | ||
showDisc=False, | ||
showAngles=False, | ||
showErrors=False, | ||
) | ||
rh.scale(0.15) # scale histogram to make it small | ||
rh.pos(hyp.getPoint(i)) # set its position on the surface | ||
rh.orientation(hyp.normalAt(i)) # orient it along normal | ||
radhistos.append(rh) | ||
|
||
show(hyp, radhistos, at=1, interactive=True) |
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,14 @@ | ||
from vtkplotter import * | ||
import numpy as np | ||
|
||
data1 = np.random.randn(500)*3+10 | ||
data2 = np.random.randn(500)*2+ 7 | ||
|
||
h1 = histogram(data1, fill=True, outline=False, errors=True) | ||
h2 = histogram(data2, fill=False, lc='firebrick', lw=4) | ||
h2.z(0.1) # put h2 in front of h1 | ||
|
||
h1.scale([1, 0.2, 1]) # set a common y-scaling factor | ||
h2.scale([1, 0.2, 1]) | ||
|
||
show(h1, h2, bg='white', axes=1) |
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 |
---|---|---|
@@ -1,41 +1,50 @@ | ||
""" | ||
Example of drawing objects on different windows | ||
and/or subwindows within the same window. | ||
We split the main window in a 25 subwindows and draw something | ||
in specific windows numbers. | ||
We split the main window in many subwindows and draw | ||
somethingon specific windows numbers. | ||
Then open an independent window and draw a shape on it. | ||
""" | ||
print(__doc__) | ||
from vtkplotter import * | ||
|
||
from vtkplotter import Plotter, Text, datadir | ||
|
||
|
||
########################################################################## | ||
# this is one instance of the class Plotter with 5 raws and 5 columns | ||
vp1 = Plotter(shape=(5, 5), axes=0, bg="white") | ||
# having set shape=(n,m), script execution after the show() is not held | ||
vp1 = Plotter(shape=(5,5), axes=0, bg="white") | ||
|
||
# set a different background color for a specific subwindow (the last one) | ||
vp1.renderers[24].SetBackground(0.8, 0.9, 0.9) # use vtk method SetBackground() | ||
|
||
# load the actors and give them a name | ||
a = vp1.load(datadir+"airboat.vtk").legend("some legend") | ||
a = vp1.load(datadir+"airboat.vtk") | ||
b = vp1.load(datadir+"cessna.vtk", c="red") | ||
c = vp1.load(datadir+"atc.ply") | ||
|
||
# show a text in each renderer | ||
for i in range(25): | ||
txt = Text("renderer\nnr."+str(i), c='k', s=0.5, font='arial') | ||
vp1.show(txt, at=i, interactive=0) | ||
txt = Text("renderer\nnr."+str(i), c='k', font='arial', s=1) | ||
vp1.show(txt, at=i) | ||
|
||
vp1.show(a, at=22) | ||
vp1.show(a, at= 6) | ||
vp1.show(b, at=23) | ||
vp1.show(c, at=24, interactive=0) | ||
vp1.show(c, at=24) | ||
|
||
|
||
############################################################ | ||
########################################################################## | ||
# declare a second independent instance of the class Plotter | ||
vp2 = Plotter(pos=(500, 250), bg=(0.9, 0.9, 1)) # blue-ish background | ||
# shape can also be given as a string, e.g.: | ||
# shape="2/6" means 2 renderers above and 6 below | ||
# shape="3|1" means 3 renderers on the left and one on the right | ||
|
||
s = load(datadir+'pumpkin.vtk') | ||
|
||
#settings.multiRenderingSplittingPosition = 0.5 | ||
|
||
vp2 = Plotter(pos=(500, 250), shape='2/6') | ||
|
||
vp2.load(datadir+"porsche.ply").legend("an other window") | ||
for i in range(len(vp2.renderers)): | ||
s2 = s.clone().color(i) | ||
txt = Text('renderer #'+str(i)) | ||
vp2.show(s2, txt, at=i) | ||
|
||
vp2.show() # show and interact with mouse and keyboard | ||
interactive() |
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,15 @@ | ||
from vtkplotter import polarPlot, show | ||
import numpy as np | ||
|
||
title = "A (splined) polar plot" | ||
angles = [ 0, 20, 60, 160, 200, 250, 300, 340] | ||
distances = [0.1, 0.2, 0.3, 0.5, 0.6, 0.4, 0.2, 0.1] | ||
|
||
dn1 = polarPlot([angles, distances], deg=True, spline=False, | ||
c='green', alpha=0.5, title=title, vmax=0.6) | ||
|
||
dn2 = polarPlot([angles, np.array(distances)/2], deg=True, | ||
c='tomato', alpha=1, showDisc=False, vmax=0.6) | ||
dn2.z(0.01) # set z above 0, so that plot is visible | ||
|
||
show(dn1, dn2, axes=None, bg='white') |
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
Oops, something went wrong.