-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change the range of the axes' plots #60
Comments
Hi, @Andersongeofisco! Do you have any code to go with your question so that I can help you implement this with your workflow? It sounds like you are using PyVista strictly for plotting and passing a 3D numpy array to the Plotter's import numpy as np
import pyvista as pv
# Create a 3D numpy array like what is used
arr = np.arange(1000).reshape((10,10,10))
# Create a PyVista UniformGrid for the 3D array
grid = pv.UniformGrid()
# Set the spatial reference
grid.dimensions = np.array(arr.shape) + 1 #dim + 1 because cells
grid.origin = (-5, -5, -5)
grid.spacing = (1, 1, 1)
# Add data arrays
grid['data'] = arr.ravel(order='F')
# Now plot the properly referenced dataset
grid.plot(show_grid=True, show_edges=True) |
Hi @banesullivan ! Here is a example of my code. import pyvista as pv
import numpy as np
ns=401
nv=21
nps=52
dado1=open("dvp3.ad",'rb')
d=np.fromfile(dado1,dtype=np.float32,count=ns*nv*nps).reshape([ns,nv,nps],order='F')
a=pv.wrap(d)
outline = a.outline()
slices = a.slice_orthogonal(x=401,y=5,z=52)
p = pv.Plotter()
p.add_mesh(outline)
p.add_mesh(slices,cmap='jet',opacity=1.,stitle="Semblance")
p.add_volume(a,cmap='jet',stitle="Semblance")
p.add_text("Semblance",position='upper_edge')
p.show_bounds(xlabel='Time',ylabel='Velocity',zlabel='Slope',location='outer')
p.show() |
So the a = pv.UniformGrid()
# Set the spatial reference
a.dimensions = np.array(arr.shape) + 1 #dim + 1 because cells
a.origin = (-5, -5, -5)
a.spacing = (1, 1, 1)
# Add data arrays
a['Semblance'] = d.ravel(order='F') |
Thanks @banesullivan for your help! You helped a lot this young phd student :) |
I will try it and if everything works well I will return to say thanks. |
Hi @banesullivan ! I tried your tip, but I get another problem now. If I try to use the a object that was created to add_volume or slice I have this error message: ERROR:root:Cell Scalars not supported Here is my code: import pyvista as pv ns=401 a = pv.UniformGrid() a.dimensions = np.array(d.shape) + 1 #dim + 1 because cells outline = a.outline() |
Ah, my bad. Take away that Sent with GitHawk |
Thanks again @banesullivan! Everything is working well now. Thank you very much! |
Hello everyone! I hope that everyone is fine. I have a doubt :) I'd like to know if it is possible to change the range of the axes in a volume plot for example. The axes of my plots always start from 0 to length of my 3d numpy array, I'd like to plot for example something like, -5 to 5 (-5,-4,-3,-2,-1,0,1,2,3,4,5) instead (0,1,2,3,4,5,6,7,8,9,10) at the axes.
Thanks!
The text was updated successfully, but these errors were encountered: