funnel() got an unexpected keyword argument 'is_vertical'
时间: 2023-07-31 12:08:08 浏览: 47
如果你使用的是较早的版本的 plotly.express 库,可能不支持 `is_vertical` 参数,这时你可以使用 `orientation` 参数来实现漏斗图的竖向展示。
具体来说,你需要将 `orientation` 参数设置为 `"v"`,示例如下:
```
import plotly.express as px
data = dict(
number=[1000, 600, 400, 200],
stage=["访问网站", "注册账号", "付款", "购买"]
)
fig = px.funnel(data, x="number", y="stage", orientation="v")
fig.show()
```
在上述代码中,`orientation="v"` 参数指定漏斗图竖向展示。
相关问题
px.funnel的name 'px' is not defined
This error message means that you are trying to access the attribute 'funnel' of an object named 'px', but the variable 'px' has not been defined in your code.
To fix this error, you need to first define the variable 'px' and assign it to an object that has a 'funnel' attribute. For example:
```python
class MyClass:
funnel = "example funnel"
px = MyClass()
print(px.funnel)
```
This will create an instance of the `MyClass` class, assign it to the variable `px`, and then access its `funnel` attribute to print "example funnel".
Make sure that you have defined the object correctly and that the variable name is spelled correctly in your code.
jupyter notebook 里funnel.render_notebook()看不见图片
如果在Jupyter Notebook中使用`funnel.render_notebook()`方法无法显示图片,可以尝试以下两种方法:
1. 在Notebook中添加以下代码,以启用notebook渲染器:
```python
from pyecharts.render import NotebookRender
NotebookRender()
```
2. 将`funnel.render_notebook()`替换为`funnel.render('file.html')`,然后在Notebook中使用以下代码来显示图表:
```python
from IPython.display import IFrame
IFrame(src='./file.html', width=700, height=600)
```
其中,`src`参数为HTML文件的路径,`width`和`height`参数为图表的宽度和高度。
请注意,第二种方法将在Notebook中生成一个HTML文件,因此需要确保在Notebook所在的目录中具有写入权限。