希望此问题不是多余的。我试图以类似于Gapminder示例的方式可视化数据。使用px.data.gapminder()进行的测试运行出色。但是,当我尝试在自身数据的形状相似的Excel文件上传输原理时,会出现标题错误。这里的代码:
import plotly_express as px
import pandas as pd
import matplotlib as plt
Heisei = pd.read_excel("日本ダム/NihonGapmindFormTest.xlsx")
print(Heisei)
#display of Japanese characters
plt.rcParams['font.sans-serif'] = ['Kozuka Mincho Pr6N']
plt.rcParams['font.serif'] = ['Kozuka Mincho Pr6N']
px.scatter(Heisei, x="Inauguration Year", y="Percent to Dead Volume", animation_frame="Year", animation_group="Dam Name",
size="Percent to Whole Volume", color="Dam Name", hover_name="Dam Name",
#log_y = True,
size_max=45, range_x=[1910,2020], range_y=[-100,1000])
该表不包含NaN。 Dash.ly似乎未安装。至少无法将其点子卸载,因为找不到。
这是完整的错误警告。
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-2fdd1e6f0c53> in <module>()
2 size="Percent to Whole Volume", color="Dam Name", hover_name="Dam Name",
3 #log_y = True,
----> 4 size_max=45, range_x=[1910,2020], range_y=[-100,1000])
~\Anaconda3\envs\tensorflow\lib\site-packages\plotly_express\_chart_types.py in scatter(data_frame, x, y, color, symbol, size, hover_name, hover_data, text, facet_row, facet_col, error_x, error_x_minus, error_y, error_y_minus, animation_frame, animation_group, category_orders, labels, color_discrete_sequence, color_discrete_map, color_continuous_scale, color_continuous_midpoint, symbol_sequence, symbol_map, opacity, size_max, marginal_x, marginal_y, trendline, trendline_color_override, log_x, log_y, range_x, range_y, render_mode, title, template, width, height)
59 In a scatter plot, each row of `data_frame` is represented by a symbol mark in 2D space.
60 """
---> 61 return make_figure(args=locals(), constructor=go.Scatter)
62
63
~\Anaconda3\envs\tensorflow\lib\site-packages\plotly_express\_core.py in make_figure(args, constructor, trace_patch, layout_patch)
653 def make_figure(args, constructor, trace_patch={}, layout_patch={}):
654 trace_specs, grouped_mappings, sizeref, color_range = infer_config(
--> 655 args, constructor, trace_patch
656 )
657 grouper = [x.grouper or one_group for x in grouped_mappings] or [one_group]
~\Anaconda3\envs\tensorflow\lib\site-packages\plotly_express\_core.py in infer_config(args, constructor, trace_patch)
589 sizeref = 0
590 if "size" in args and args["size"]:
--> 591 sizeref = args["data_frame"][args["size"]].max() / (
592 args["size_max"] * args["size_max"]
593 )
TypeError: 'method' object is not subscriptable
如前所述,我希望这不是多余的。如果是这样,请将我链接到相应的问题。
提前致谢, 托比亚斯