Пример #1
0
counts = [1946, 8993, 3042, 1190, 1477, 0, 0]
percent = [11.68909178, 54.01850072, 18.27246516, 7.14800577, 8.87193657, 0, 0]
labels = [
    '<100', '100-250', '250-500', '500-750', '750-1000', '1000-2000', '>2000'
]
colors = colorMap(range(len(counts)), "hot")

plt = plot(
    [counts, labels, colors],
    mode="bars",
    ylim=(0, 10500),
    aspect=4 / 3,
    axes=dict(
        htitle="Clusters in lux range",
        hTitleItalic=False,
        xLabelRotation=35,
        xLabelSize=0.02,
        tipSize=0,  # axes arrow tip size
    ),
)

for i in range(len(percent)):
    val = precision(percent[i], 3) + '%'
    txt = Text3D(val,
                 pos=(plt.centers[i], counts[i]),
                 justify="bottom-center",
                 c="blue2")
    plt += txt.scale(200).shift(0, 150, 0)

plt.show(size=(1000, 750), zoom=1.3, viewup='2d').close()
Пример #2
0
"""Customizing Axes.
Cartesian planes can be displaced
from their lower-range default position"""
from vedo import Sphere, Axes, precision, show

sph = Sphere().scale([4, 3, 2]).shift(5, 6, 7).c('green2', 0.1)

axs = Axes(
    sph,  # build axes for object sph
    xtitle="x axis",
    ytitle="y axis",
    ztitle="z axis",
    htitle='An ellipsoid at ' + precision(sph.centerOfMass(), 2),
    hTitleFont=1,
    hTitleColor='red3',
    zxGrid=True,
    xyFrameLine=2,
    yzFrameLine=2,
    zxFrameLine=2,
    xyFrameColor='red3',
    yzFrameColor='green3',
    zxFrameColor='blue3',
    xyShift=0.2,  # move xy plane 20% along z
    yzShift=0.2,  # move yz plane 20% along x
    zxShift=0.2,  # move zx plane 20% along y
)

show(sph, axs, __doc__)
Пример #3
0
          )
plt += DashedLine(x, y)

# Fit points and evaluate, with a boostrap and Monte-Carlo technique,
# the correct errors and error bands. Return a Line object:
pfit = fit([x, y+noise],
           deg=deg,        # degree of the polynomial
           niter=500,      # nr. of MC iterations to compute error bands
           nstd=2,         # nr. of std deviations to display
           xerrors=xerrs,  # optional array of errors on x
           yerrors=yerrs,  # optional array of errors on y
           vrange=(-3,15), # specify the domain of fit
          )

plt += [pfit, pfit.errorBand, *pfit.errorLines] # add these objects to Plot

txt = "fit coefficients:\n " + precision(pfit.coefficients, 2) \
    + "\n\pm" + precision(pfit.coefficientErrors, 2) \
    + "\n\Chi^2_\nu  = " + precision(pfit.reducedChi2, 3)
plt += Text3D(txt, s=0.42, font='VictorMono').pos(2,-2).c('k')

# Create an histo to show the correlation of fit parameters
h = histogram(pfit.MonteCarloCoefficients[:,0],
              pfit.MonteCarloCoefficients[:,1],
              title="parameters correlation",
              xtitle='coeff_0', ytitle='coeff_1',
              cmap='bone_r', scalarbar=True)
h.scale(150).shift(-1,11) # make it a lot bigger and move it

show(plt, h, zoom=1.3, mode="image").close()
Пример #4
0
"""Find the overlap area of 2 triangles"""
from vedo import Mesh, precision, show
import numpy as np

verts1 = [(1.9, 0.50), (2.1, 0.8), (2.4, 0.4)]
verts2 = [(2.3, 0.75), (1.7, 0.4), (2.1, 0.3)]
faces = [(0, 1, 2)]

m1 = Mesh([verts1, faces]).c('g').lw(4).wireframe()
m2 = Mesh([verts2, faces]).c('b').lw(4).wireframe()

a1 = precision(m1.area(), 3) + " \mum\^2"
a2 = precision(m2.area(), 3) + " \mum\^2"

vig1 = m1.vignette('Triangle 1\nA=' + a1,
                   point=(2.1, 0.7),
                   s=0.012,
                   offset=(-0.3, 0.04))
vig2 = m2.vignette('Triangle 2\nA=' + a2,
                   point=(1.9, 0.4),
                   s=0.012,
                   offset=(0.2, -0.2))

m3 = m1.clone().wireframe(False).c('tomato').lw(0)

zax = (0, 0, 1)
v0, v1, v2 = np.insert(np.array(verts2), 2, 0, axis=1)

m3.cutWithPlane(origin=v0, normal=np.cross(zax, v1 - v0))
if m3.NPoints():
    m3.cutWithPlane(origin=v1, normal=np.cross(zax, v2 - v1))