質問編集履歴
9
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
これを1つのグラフが更新されるように修正したいのですが、
|
5
5
|
どなたか教えていただければと思います。
|
6
6
|
よろしくお願いします。
|
7
|
+
```python
|
7
8
|
|
8
|
-
|
9
9
|
import pandas as pd
|
10
10
|
import plotly.express as px
|
11
11
|
import streamlit as st
|
@@ -44,4 +44,6 @@
|
|
44
44
|
df = df[~df['X'].isin(df_final['X'])]
|
45
45
|
counter = counter + 1
|
46
46
|
except:
|
47
|
-
break
|
47
|
+
break
|
48
|
+
|
49
|
+
```
|
8
内容の修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
plotlyのグラフ更新
|
1
|
+
plotlyのグラフ表示の更新
|
body
CHANGED
@@ -1,18 +1,11 @@
|
|
1
|
-
現在
|
1
|
+
現在、Streamlitを使って、グラフに表示されている点を選択すると
|
2
|
+
グラフが更新され、先ほど選択した点が消えた状態になれば良いのですが、
|
3
|
+
現状は、どんどん新しいグラフが追加されていくようになっております。
|
2
|
-
|
4
|
+
これを1つのグラフが更新されるように修正したいのですが、
|
3
|
-
何か方法などありますでしょうか??
|
4
|
-
一応、下のもので、削除はされていくのですが、削除するたびに更新ではなく、
|
5
|
-
グラフが新しく作成される状態になりました。
|
6
|
-
|
5
|
+
どなたか教えていただければと思います。
|
7
|
-
|
6
|
+
よろしくお願いします。
|
8
|
-
DuplicateWidgetID: There are multiple identical st.streamlit_plotly_events.plotly_events widgets with the same generated key.
|
9
7
|
|
10
|
-
When a widget is created, it's assigned an internal key based on its structure. Multiple widgets with an identical structure will result in the same internal key, which causes this error.
|
11
8
|
|
12
|
-
To fix this error, please pass a unique key argument to st.streamlit_plotly_events.plotly_events.
|
13
|
-
*******************************************************
|
14
|
-
よろしくお願いいたします。
|
15
|
-
|
16
9
|
import pandas as pd
|
17
10
|
import plotly.express as px
|
18
11
|
import streamlit as st
|
@@ -24,15 +17,31 @@
|
|
24
17
|
df2 = pd.DataFrame({'X': [1, 2, 3, 4, 5, 6], 'Y': [1, 2, 3, 4, 5, 6]})
|
25
18
|
|
26
19
|
aaa = st.checkbox('AAA')
|
20
|
+
counter = 0
|
27
21
|
|
28
22
|
while aaa == True:
|
29
23
|
st.write(df)
|
24
|
+
st.write(counter)
|
25
|
+
key = "hover" +'_'+ str(counter)
|
26
|
+
st.write(key)
|
30
27
|
fig1 = px.scatter(df, x='X', y='Y',color_discrete_sequence=["red"])
|
31
28
|
fig2 = px.line(df2,x='X', y='Y')
|
32
29
|
fig1.update_layout(clickmode='select')
|
33
30
|
fig = go.Figure(data=fig1.data + fig2.data)
|
31
|
+
selected_points = plotly_events(
|
32
|
+
fig,
|
33
|
+
click_event = False,
|
34
|
+
select_event = True,
|
35
|
+
override_height = 500,
|
36
|
+
override_width = "100%",
|
37
|
+
key = key
|
38
|
+
)
|
39
|
+
try:
|
34
|
-
|
40
|
+
selected_points = eval(selected_points)
|
35
|
-
|
41
|
+
df_final = df.iloc[[v['pointIndex'] for v in selected_points]]
|
36
|
-
|
42
|
+
st.write(df_final)
|
37
|
-
|
43
|
+
st.write('削除後の点は以下')
|
38
|
-
|
44
|
+
df = df[~df['X'].isin(df_final['X'])]
|
45
|
+
counter = counter + 1
|
46
|
+
except:
|
47
|
+
break
|
7
ソース変更、文言の修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
plotlyのグラフ
|
1
|
+
plotlyのグラフ更新(streamlit)
|
body
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
現在、Plotlyでのグラフ表示をしています。
|
2
2
|
当初描画されているグラフを下の数値を使って更新したいです。
|
3
3
|
何か方法などありますでしょうか??
|
4
|
-
|
4
|
+
一応、下のもので、削除はされていくのですが、削除するたびに更新ではなく、
|
5
|
-
|
5
|
+
グラフが新しく作成される状態になりました。
|
6
|
+
また、エラーも出るようになってしまっています。
|
7
|
+
*******************************************************
|
8
|
+
DuplicateWidgetID: There are multiple identical st.streamlit_plotly_events.plotly_events widgets with the same generated key.
|
9
|
+
|
10
|
+
When a widget is created, it's assigned an internal key based on its structure. Multiple widgets with an identical structure will result in the same internal key, which causes this error.
|
11
|
+
|
12
|
+
To fix this error, please pass a unique key argument to st.streamlit_plotly_events.plotly_events.
|
13
|
+
*******************************************************
|
6
14
|
よろしくお願いいたします。
|
7
15
|
|
8
16
|
import pandas as pd
|
@@ -15,21 +23,16 @@
|
|
15
23
|
df = pd.DataFrame({'X': [1, 2, 3, 4, 5, 6], 'Y': [1, 2, 3, 4, 5, 6]})
|
16
24
|
df2 = pd.DataFrame({'X': [1, 2, 3, 4, 5, 6], 'Y': [1, 2, 3, 4, 5, 6]})
|
17
25
|
|
26
|
+
aaa = st.checkbox('AAA')
|
18
27
|
|
28
|
+
while aaa == True:
|
29
|
+
st.write(df)
|
19
|
-
fig1 = px.scatter(df, x='X', y='Y',color_discrete_sequence=["red"])
|
30
|
+
fig1 = px.scatter(df, x='X', y='Y',color_discrete_sequence=["red"])
|
20
|
-
fig2 = px.line(df2,x='X', y='Y')
|
31
|
+
fig2 = px.line(df2,x='X', y='Y')
|
21
|
-
fig1.update_layout(clickmode='select')
|
32
|
+
fig1.update_layout(clickmode='select')
|
22
|
-
fig = go.Figure(data=fig1.data + fig2.data)
|
33
|
+
fig = go.Figure(data=fig1.data + fig2.data)
|
23
|
-
selected_points = plotly_events(fig, click_event=False, select_event=True)
|
34
|
+
selected_points = plotly_events(fig, click_event=False, select_event=True)
|
24
|
-
|
25
|
-
df_final = df.iloc[[v['pointIndex'] for v in selected_points]]
|
35
|
+
df_final = df.iloc[[v['pointIndex'] for v in selected_points]]
|
26
|
-
st.write(df_final)
|
36
|
+
st.write(df_final)
|
27
|
-
|
28
|
-
delete_button = st.button('削除')
|
29
|
-
|
30
|
-
if delete_button == True:
|
31
37
|
st.write('削除後の点は以下')
|
32
|
-
|
38
|
+
df = df[~df['X'].isin(df_final['X'])]
|
33
|
-
st.write(df_final2)
|
34
|
-
else:
|
35
|
-
st.write('まだ')
|
6
内容の修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
plotlyのグラフの更新(streamlit)
|
body
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
|
1
|
+
現在、Plotlyでのグラフ表示をしています。
|
2
|
-
その中で、変更前の数値を使ってグラフを描画しており、
|
3
|
-
|
2
|
+
当初描画されているグラフを下の数値を使って更新したいです。
|
4
|
-
|
5
3
|
何か方法などありますでしょうか??
|
6
4
|
ソース内でいうと、最終的に出てきたdf_final2を使ってscatterを描画したい(更新したい)です。
|
7
5
|
ちなみに、px.lineの値はそのままです。
|
5
修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
streamlitでのグラフの更新
|
body
CHANGED
File without changes
|
4
修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
streamlitでのグラフの更新(計算後の値を使う)
|
1
|
+
shuusei streamlitでのグラフの更新(計算後の値を使う)
|
body
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
df = pd.DataFrame({'X': [1, 2, 3, 4, 5, 6], 'Y': [1, 2, 3, 4, 5, 6]})
|
18
18
|
df2 = pd.DataFrame({'X': [1, 2, 3, 4, 5, 6], 'Y': [1, 2, 3, 4, 5, 6]})
|
19
19
|
|
20
|
+
|
20
21
|
fig1 = px.scatter(df, x='X', y='Y',color_discrete_sequence=["red"])
|
21
22
|
fig2 = px.line(df2,x='X', y='Y')
|
22
23
|
fig1.update_layout(clickmode='select')
|
@@ -25,5 +26,12 @@
|
|
25
26
|
|
26
27
|
df_final = df.iloc[[v['pointIndex'] for v in selected_points]]
|
27
28
|
st.write(df_final)
|
29
|
+
|
30
|
+
delete_button = st.button('削除')
|
31
|
+
|
32
|
+
if delete_button == True:
|
33
|
+
st.write('削除後の点は以下')
|
28
|
-
df_final2 = df2[~df2['X'].isin(df_final['X'])]
|
34
|
+
df_final2 = df2[~df2['X'].isin(df_final['X'])]
|
29
|
-
st.write(df_final2)
|
35
|
+
st.write(df_final2)
|
36
|
+
else:
|
37
|
+
st.write('まだ')
|
3
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
何か方法などありますでしょうか??
|
6
6
|
ソース内でいうと、最終的に出てきたdf_final2を使ってscatterを描画したい(更新したい)です。
|
7
|
+
ちなみに、px.lineの値はそのままです。
|
7
8
|
よろしくお願いいたします。
|
8
9
|
|
9
10
|
import pandas as pd
|
2
書式の改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -16,7 +16,6 @@
|
|
16
16
|
df = pd.DataFrame({'X': [1, 2, 3, 4, 5, 6], 'Y': [1, 2, 3, 4, 5, 6]})
|
17
17
|
df2 = pd.DataFrame({'X': [1, 2, 3, 4, 5, 6], 'Y': [1, 2, 3, 4, 5, 6]})
|
18
18
|
|
19
|
-
# Select other Plotly events by specifying kwargs
|
20
19
|
fig1 = px.scatter(df, x='X', y='Y',color_discrete_sequence=["red"])
|
21
20
|
fig2 = px.line(df2,x='X', y='Y')
|
22
21
|
fig1.update_layout(clickmode='select')
|
1
ソース追加
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
streamlit
|
1
|
+
streamlitでのグラフの更新(計算後の値を使う)
|
body
CHANGED
@@ -1,5 +1,29 @@
|
|
1
|
-
streamlitを使ってグラフ表示をしてい
|
1
|
+
streamlitを使ってグラフの表示をしています。
|
2
|
-
グラフ内で値を選択後、選択された数値を削除するのですが、
|
3
|
-
その
|
2
|
+
その中で、変更前の数値を使ってグラフを描画しており、
|
3
|
+
何か計算(解析)した値がでしだい、前のグラフを計算後の数値を使って更新したいと思っております。
|
4
|
+
|
4
5
|
何か方法などありますでしょうか??
|
6
|
+
ソース内でいうと、最終的に出てきたdf_final2を使ってscatterを描画したい(更新したい)です。
|
5
|
-
よろしくお願いいたします。
|
7
|
+
よろしくお願いいたします。
|
8
|
+
|
9
|
+
import pandas as pd
|
10
|
+
import plotly.express as px
|
11
|
+
import streamlit as st
|
12
|
+
from streamlit_plotly_events import plotly_events
|
13
|
+
import plotly.offline as offline
|
14
|
+
import plotly.graph_objects as go
|
15
|
+
|
16
|
+
df = pd.DataFrame({'X': [1, 2, 3, 4, 5, 6], 'Y': [1, 2, 3, 4, 5, 6]})
|
17
|
+
df2 = pd.DataFrame({'X': [1, 2, 3, 4, 5, 6], 'Y': [1, 2, 3, 4, 5, 6]})
|
18
|
+
|
19
|
+
# Select other Plotly events by specifying kwargs
|
20
|
+
fig1 = px.scatter(df, x='X', y='Y',color_discrete_sequence=["red"])
|
21
|
+
fig2 = px.line(df2,x='X', y='Y')
|
22
|
+
fig1.update_layout(clickmode='select')
|
23
|
+
fig = go.Figure(data=fig1.data + fig2.data)
|
24
|
+
selected_points = plotly_events(fig, click_event=False, select_event=True)
|
25
|
+
|
26
|
+
df_final = df.iloc[[v['pointIndex'] for v in selected_points]]
|
27
|
+
st.write(df_final)
|
28
|
+
df_final2 = df2[~df2['X'].isin(df_final['X'])]
|
29
|
+
st.write(df_final2)
|