為有一個很長的帖子道歉。我正在開發一個可視化效果,表示不同位置的每周庫存值。我能夠通過單擊圖例從圖形中隱藏某些位置,但y軸不會自行更新。這就是為什么我試圖實現復選框組來過濾圖形的項目。但是,我可以繪制圖形,但是每當我在 CheckBox 組中取消選擇某些項目時,圖形都不會自行更新。您可以在下面找到輸出的圖像。任何幫助都將是有用的。P.S:為了重現輸出處理,必須首先運行數據代碼,然后運行圖形代碼。謝謝, E輸出:代碼的輸出數據 : 鏈接處理數據:import pandas as pdimport numpy as npdataset_inventory = pd.read_excel('weekly_inventory_data.xls')df = dataset_inventory.copy()df = df.fillna(0)df = df.replace('-',0)resource = "??????????üü"target = "cCgGiIoOsSuU"translate = str.maketrans(resource,target)df['Location']= df['Location'].str.translate(translate)df.columns = [x.lower() if type(x)==str else x for x in df.columns]df['location'] = [x.lower() for x in df['location']]df1 = df.copy()df2 =df.copy()for column in df2: if type(column) == int: df2[column] = [1 if x>0 else 0 for x in df2[column]] else: pass def table(df,info): pivot = df.groupby('location').sum().T pivot.columns.names = [''] pivot['total'] = pivot.sum(axis=1) pivot.reset_index(level=0, inplace=True) pivot.insert(loc=0, column='year', value=np.where(pivot['index'].apply(lambda x: x > 16), 2015, 2016)) pivot.insert(loc=2, column='year_week', value=pivot['year'].astype(str) +'_'+ pivot['index'].astype(str)) pivot.reset_index(inplace=True) pivot.rename(columns={'level_0' :'observation','index':'week'}, inplace=True) pivot['year_week'] = pd.Categorical(pivot.year_week, ordered=True) pivot['observation'] = [x+1 for x in pivot['observation']] pivot.rename(columns={'cayirova' :'cayirova_'+info, 'orhanli' :'orhanli_'+info, 'fason' :'fason_'+info, 'samandira' :'samandira_'+info, 'gebze' :'gebze_'+info, 'sultanbeyli' :'sultanbeyli_'+info, 'yenidogan' :'yenidogan_'+info, 'total' :'total_'+info }, inplace=True) return pivotinput1='qty'input2='wh'df1 = table(df1,input1)df2 = table(df2,input2)
1 回答
慕虎7371278
TA貢獻1802條經驗 獲得超4個贊
您不需要復選框組。只需添加某個地方。fig.y_range.only_visible = True
您不需要復選框組。只需添加某個地方。fig.y_range.only_visible = True
添加回答
舉報
0/150
提交
取消
