简体   繁体   English

在 set_proj_type 方法中设置 focal_length 失败 Matplotlib 3D plot

[英]Setting focal_length fails in set_proj_type method in Matplotlib 3D plot

I am animating some data using mpl_toolkits.mplot3d.我正在使用 mpl_toolkits.mplot3d 为一些数据制作动画。 When I attempt to set the focal length in the set_proj_type method, it fails.当我尝试在 set_proj_type 方法中设置焦距时,它失败了。

When I use the following, the code runs with a default focal length of 1.当我使用以下代码时,代码以默认焦距 1 运行。

ax.set_proj_type('persp')

But when I attempt to change the focal length as follows, it fails to run但是当我尝试如下更改焦距时,它无法运行

ax.set_proj_type('persp', focal_length = 0.2)

and gives me this error:并给我这个错误:

TypeError: set_proj_type() got an unexpected keyword argument 'focal_length'

But this is exactly how the focal length is shown to be specified in the Matplotlib documentation .但这正是Matplotlib 文档中指定焦距的方式。

I am running Python 3.8.10 on Linux and Matplotlib version 3.1.2 if that matters.如果重要的话,我在 Linux 和 Matplotlib 版本 3.1.2 上运行 Python 3.8.10。

I've found how to install the latest stable release 3.6.3 (why I was not getting it through the package manager I do not know).我找到了如何安装最新的稳定版本 3.6.3(我不知道为什么我没有通过 package 管理器获取它)。

Apparently the focal_length attribute was not available in Matplotlib version 3.1.2.显然 focal_length 属性在 Matplotlib 版本 3.1.2 中不可用。 Updating to the new release makes it available.更新到新版本使其可用。

But now the camera distance attribute has been deprecated for 3D plots, which breaks something that was working for me.但现在 3D 图的相机距离属性已被弃用,这打破了对我有用的东西。 I'll post that in a separate question.我会在一个单独的问题中发布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM