Plotly 3d vedo equivalent
See original GitHub issueAfter familiarizing myself with the python plotly module, I find that the rendering is rather slow; especially for iso volumes. To evaluate this I shall include some code, the effect becomes more apparent as the value of n, a power of two in this instance, is increased.
Perhaps you’re able to provide the equivalent code using vedo, then I might make a comparison; this will also add to your examples.
If possible, a render to screen, rather than the web browser, as this may be faster; though this may also be sent to a web page through some vedo code that I’m not familiar with.
# Three volume plots ; using subplots.
# Some from a 3d array .
# Now using 3d array and fftn, fftshift, ifftn .
import plotly.offline as py # attempting to speed up render.
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import numpy as np
from scipy.fftpack import fftn, ifftn, fftshift
import scipy.signal as sg
# ------------------------------------------------------------------
# np.ndarray(shape=(2,2), dtype=float, order='F')
n=64
m=n
p=n
# arr = np.ndarray(shape=(n,m,p), dtype=float)
# Generate data
p1=p
m1=m
n1=n
p1=int(p1/4)
m1=int(m1/9)
n1=int(n1/5)
X, Y, Z = np.mgrid[:n, :m, :p]
vol = np.zeros((n, m, p))
x1=X.flatten()
y1=Y.flatten()
z1=Z.flatten()
for k in range(p1):
for j in range(m1):
for i in range(n1):
vol[i,j,k]=1
#vol[i,j,k]=k*m1*n1 + j*n1 + i
# ------------------------------
vol /= vol.max()
volf = fftn(vol) # spectra .
volg = volf # unaltered, for further processes, possibly ifftn .
# other code here .
volg = ifftn(volg)
volg = volg.real
# Preprocess spectra before 3d graph .
volf = abs(volf)
volf = fftshift(volf) # for centered spectra.
volf /= volf.max()
Ag=10^6
volf = np.log(Ag*volf +1)/np.log(Ag+1) # to bring out detail .
# ------------------------- Graphing results ---------------------------
# Make figure with subplots
fig = make_subplots(
rows=3, cols=1,
specs=[[{'type': 'Volume'}], [{'type': 'Volume'}],
[{'type': 'Volume'}]])
# Initialize figure with 3 3D subplots
#subplot_titles=("data 3d", "3d log|fft|", "3d Real(ifft)")
# )
# ------------------------------------------------------------------
# adding volumes to subplots.
fig.add_trace(
go.Volume(
x=x1,
y=y1,
z=z1,
value=vol.flatten(),
isomin=0.1,
isomax=1.0,
opacity=0.1, # needs to be small to see through all surfaces
surface_count=17 # needs to be a large number for good volume rendering
),
row=1, col=1
)
fig.add_trace(
go.Volume(
x=x1,
y=y1,
z=z1,
value=volf.flatten(),
isomin=0.1,
isomax=1.0,
opacity=0.1, # needs to be small to see through all surfaces
surface_count=17 # needs to be a large number for good volume rendering
),
row=2, col=1
)
fig.add_trace(
go.Volume(
x=x1,
y=y1,
z=z1,
value=volg.flatten(),
isomin=0.1,
isomax=1.0,
opacity=0.1, # needs to be small to see through all surfaces
surface_count=17 # needs to be a large number for good volume rendering
),
row=3, col=1
)
fig.update_layout(
title_text='3D subplots with different colorscales',
height=1800,
width=1024
)
#fig.show()
# plot offline
py.plot(fig, filename='isosurface.html')
# ------------------------------------------------------------------
quit()
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (6 by maintainers)
Top Results From Across the Web
3d surface plots in Python - Plotly
Detailed examples of 3D Surface Plots including changing color, size, log axes, and more in Python.
Read more >Plotly express in Python
The plotly.express module (usually imported as px ) contains functions that can create entire figures at once, and is referred to as Plotly...
Read more >Intro to 3D Visualization | Dash for Python Documentation | Plotly
The view is a 3D View that can do Geometry rendering for meshes or Volume rendering for 3D images. The view can be...
Read more >3d axes in Python - Plotly
Detailed examples of 3D Axes including changing color, size, log axes, and more in Python. ... How to format axes of 3d plots...
Read more >Plotly 3D plot in python - Stack Overflow
I want to make 3D plot in python using plotly. Actually its the first step of an animation but first I need to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Continuing the theme of 2d Discrete Fourier Transform.
These are examples of the use of sub arrays and DFTs to evaluate a larger DFT. There’s more to do before this is in a familiar format, in particular OFT(), should be more like a standard dft.
You don’t need to import numba to run the last few examples, if you don’t then comment out all instances of the @jit function decorator. Bound to run slower after this.
Calls to fft routines use 10% of the process time, vedo appears to use most of the rest.