我尝试使用Shapelets,我尝试了altair示例,但我遇到了一个问题:从shapelets.apps导入DataApp时,它说规范不存在,TypeError:Widget.init()获得了意外的关键字参数'spec'
import altair as alt
import pandas as pd
app = DataApp(name=""altair example"")
# Define the data source
source = pd.DataFrame({'Horsepower': [130, 165, 150, 150, 140, 198],
'Miles_per_Gallon': [27.0, 28.0, 25.0, 25.0, 27.0, 17.0],
'Origin': ['USA', 'USA', 'USA', 'USA', 'USA', 'Europe'],
'Name': ['mazda rx4', 'mazda rx4 wag', 'datsun 710', 'hornet 4 drive', 'hornet sportabout', 'volvo 142e']})
# Define the Altair chart
spec = alt.Chart(source).mark_circle(size=60).encode(
x='Horsepower',
y='Miles_per_Gallon',
color='Origin',
tooltip=['Name', 'Origin', 'Horsepower', 'Miles_per_Gallon']
).interactive()
# Create the Altair chart component
altair_chart = app.altair_chart(title='Altair Chart 2', spec=spec)
# Add the chart to the app
app.place(altair_chart)
# Register the app
app.register()"
有人能帮我吗?我会很感激的
1条答案
按热度按时间osh3o9ms1#
是的,您需要使用图表,因为规范不是Shapelets的参数。请从shapelets尝试此操作。apps导入DataApp