To remove the empty square in your Pyecharts Bar chart, you need to modify the .add_yaxis() method. Instead of using ".add_yaxis("", year_data[str(i) + '年'].tolist(), category_gap=0)" you should use ".add_yaxis(series_name='', yaxis_data=year_data[str(i) + '年'].tolist(), category_gap=0)". This change ensures that the chart correctly interprets the data and avoids generating the empty square.

You're also experiencing the error TypeError: Bar.add_yaxis() missing 1 required positional argument: 'y_axis'. This occurs because the add_yaxis method in Pyecharts requires a y_axis argument. The corrected code, ".add_yaxis(series_name='', yaxis_data=year_data[str(i) + '年'].tolist(), category_gap=0)", explicitly provides this argument, resolving the error.

Pyecharts Bar Chart: Removing Empty Square and Fixing add_yaxis Error

原文地址: https://www.cveoy.top/t/topic/cIZo 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录