Dear pyvista team,
Just started to use your package and already made some progress. So thank you already for this great piece of code.
I have a question that seems quite simple but I could not find in the doc: how can I make sure that the figure is centred in the window? I want to plot isosurfaces coming from fluid dynamics calculation. So far, I managed to read my data, create the grid, the figure, position the camera in a suitable place etc but, depending on these choices, the figure can be clipped by the figure side even though there is enough place in the window, it is just not centred. You can see what I mean with the attached figure.
Also, I don't want to select the view interactively, I have too many cases to visualise to spend that amount of time.
Description
Dear pyvista team, Just started to use your package and already made some progress. So thank you already for this great piece of code. I have a question that seems quite simple but I could not find in the doc: how can I make sure that the figure is centred in the window? I want to plot isosurfaces coming from fluid dynamics calculation. So far, I managed to read my data, create the grid, the figure, position the camera in a suitable place etc but, depending on these choices, the figure can be clipped by the figure side even though there is enough place in the window, it is just not centred. You can see what I mean with the attached figure.
Also, I don't want to select the view interactively, I have too many cases to visualise to spend that amount of time.
Example Data
temperature.pdf
Here is the code:
`
!/usr/bin/env python3
import pathlib from stagpy.stagyydata import StagyyData import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np
import pyvista as pv
pv.global_theme.color = 'white'
Directory holding all cases
ROOT = pathlib.Path("/Volumes/LaCieSSD/Convection")
case = "ra1e5_h05.66x5.66" stem = case.replace('sp', '').replace('.0', '')
sdat = StagyyData(ROOT / case)
snap = sdat.snaps[-1] isnap = snap.isnap
asp = snap.geom.nxtot / snap.geom.nztot
x, y, z = np.meshgrid(snap.geom.x_walls, snap.geom.y_walls, snap.geom.z_walls)
x, y, z = np.meshgrid(snap.geom.x_centers, snap.geom.y_centers, snap.geom.z_centers)
create the grid
grid = pv.StructuredGrid(x, y, z)
grid.cell_data['temperature'] = snap.fields['T'][..., 0].flatten(order="F")
isosurface needs point_data not cell_data
grid.point_data['Temperature'] = snap.fields['T'][..., 0].flatten(order="F")
surfc = grid.contour([0.35]) surfh = grid.contour([0.65])
filename = 'temperature.pdf'
pl = pv.Plotter(window_size=[1024, 384])
pl = pv.Plotter()
pl.camera.position = (9, 9, 3) pl.set_background('black', top='white')
pl.add_mesh(surfc, opacity=1, clim=grid.get_data_range(), color='blue') pl.add_mesh(surfh, opacity=1, clim=grid.get_data_range(), color='red')
pl.add_mesh(grid.outline_corners(), color='k')
pl.save_graphic(filename, title='Temperature in a convection model')
pl.close() `
Unfortunately, it seems difficult to share the data. But I guess the same type of issue can be made with data from examples.