python - AttributeError: module 'ternary' has no attribute 'figure'
问题描述
I'm trying out the supplied examples for ternary plots, but I'm getting the error
AttributeError: module 'ternary' has no attribute 'figure'
As far as I can tell based on some searching this seems to be due to the way the package is imported. Don't see how I can do this differently though. (did try to reinstall the package) To be clear: the file is not called ternary.py
import ternary
import matplotlib.pyplot as plt
## Boundary and Gridlines
scale = 30
figure, tax = ternary.figure(scale=scale)
figure.set_size_inches(10, 10)
figure.set_dpi(600)
# Draw Boundary and Gridlines
tax.boundary(linewidth=2.0)
tax.gridlines(color="black", multiple=6)
tax.gridlines(color="blue", multiple=2, linewidth=0.5)
# Set Axis labels and Title
fontsize = 20
tax.set_title("Simplex Boundary and Gridlines", fontsize=fontsize)
tax.left_axis_label("Left label $\\alpha^2$", fontsize=fontsize)
tax.right_axis_label("Right label $\\beta^2$", fontsize=fontsize)
tax.bottom_axis_label("Bottom label $\\Gamma - \\Omega$", fontsize=fontsize)
# Set ticks
tax.ticks(axis='lbr', linewidth=1)
# Remove default Matplotlib Axes
tax.clear_matplotlib_ticks()
ternary.plt.show()
Any ideas on how to solve this?
解决方案
Nice simple one. There are two libraries with "ternary" in their name. You must have done:
pip install ternary
This installs the wrong library; the library you want is from:
pip install python-ternary
You will want to run:
pip uninstall ternary
Prior to installing the correct version.
推荐阅读
- ruby-on-rails - 香草 Rails 安装上的 Webpacker 错误
- python - 从“55C”字符串中删除 C 并转换为数据文件中的浮点数
- python - 在 for 循环迭代期间从列表中弹出项目的正确方法是什么?
- java - 如何让我的方法计算主 char 数组中“a”的字符?
- swift - 不向 Firebase 添加用户
- redhat - Liquid 参考在 3Scale 开发人员门户中创建的新页面中不起作用?
- javascript - Event.target.ParentNode() 正在考虑所有先前交互的目标元素
- r - 将 glmnet 从二项式更改为多项式会出错
- swagger - 对象作为开放 API 规范 Swagger 上 API 中的查询字符串参数
- javascript - 从 for 循环中保存数据