华为电脑系统linux怎么用,华为电脑为什么要用linux的系统

首页 > 实用技巧 > 作者:YD1662023-05-28 20:14:38

VTK的高级API——PyVista介绍

1 说明:原始的vtk的python接口简直是太繁琐了,而且文档极其难看;与pyqt5和pyside2一样,功能强大,但是书写代码太繁琐,看着烦,不接受反驳。 所以,诞生了PyVista:

PyVista是VTK的python高级API。官方称为:“VTK for humans”: a high-level API to the Visualization Toolkit (VTK)。 Pyvista是一套继承自VTK数据格式的python工具包,由于同VTK数据对象兼容。

2 准备:

=====

2.1 官网:

https://docs.pyvista.org/index.htmlhttps://docs.pyvista.org/examples/index.htmlhttps://github.com/pyvista/pyvista

2.2 环境:

华为笔记本电脑、深度deepin-linux操作系统、python3.8和微软vscode编辑器。

2.3 安装:

pip install pyvista#本机安装#sudo pip3.8 install pyvista #慢#国内源安装,快sudo pip3.8 install -i https://mirrors.aliyun.com/pypi/simple pyvista

3 Hello world:

===========

3.1 窗口基本设置:

3.1.1 代码:

#导出模块import pyvista as pv#创建一个画板plotter,并实例化调出#plotter=绘图仪plotter = pv.Plotter(title='First',window_size=(1000,1000))#plotter = pv.Plotter()# setup camera and 展示窗口# 窗口标题名(不支持中文),窗口大小设置,在show和pv.Plotter中设置均可#plotter.show(title='First',window_size=(1000,1000))plotter.show()#关闭plotter.close()

3.1.2 注意窗口的标题名,大小设置,注释里有。

3.2 Hello world

3.2.1 代码:

import pyvista as pvplotter = pv.Plotter()#文本文字plotter.add_text(text='Hello world', position='upper_left', font_size=18, color='red',)#窗口展示plotter.show(title='Hello world',window_size=(1000,1000))plotter.close()#附注:文本字的位置#'lower_left','lower_right', 'upper_left', 'upper_right',#'lower_edge', 'upper_edge', 'right_edge', 'left_edge'

3.2.2 图:

华为电脑系统linux怎么用,华为电脑为什么要用linux的系统(13)

4 图片显示:

=========

4.1 静态图片显示

4.1.1 代码:

import pyvista as pv# Create a plotter objectplotter = pv.Plotter()#背景图片,scale显示图片大小;格式jpg,png,jpegplotter.add_background_image('/home/xgj/Desktop/VTK/Pyvista/pic.jpeg',scale=0.5)#窗口展示plotter.show(title='show picture',window_size=(1000,1000))plotter.close()

4.1.2 图:

华为电脑系统linux怎么用,华为电脑为什么要用linux的系统(14)

4.2 立体图:

========

4.2.1 代码:

import pyvista as pvimage = pv.read('/home/xgj/Desktop/VTK/Pyvista/pic.jpeg')# True image colorsimage.plot(rgb=True, cpos="xy")

4.2.2 效果图:

华为电脑系统linux怎么用,华为电脑为什么要用linux的系统(15)

5 3D-plane飞机:

============

5.1 方法一,代码:

#直接画飞机import pyvista as pvfrom pyvista import examples#mesh为网格,这里是调出飞机模块函数,实例化mesh = examples.load_airplane()#screenshot='airplane.png',保存图片png,在根目录下#mesh.plot(screenshot='airplane.png')mesh.plot()

5.2 效果图:

华为电脑系统linux怎么用,华为电脑为什么要用linux的系统(16)

上一页12345下一页

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.